# -*- coding: utf-8 -*-
'''
Created on Jul 23, 2012

@author: ymh
'''

from haystack import indexes
from ldt.ldt_utils.models import Segment 
from ldt.text.models import Annotation

class SegmentIndex(indexes.RealTimeSearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    iri_id = indexes.CharField(model_attr='iri_id', indexed=False, stored=True)
    project_id = indexes.CharField(model_attr='project_id', indexed=False, stored=True, null=True)
    ensemble_id = indexes.CharField(model_attr='ensemble_id', indexed=False, stored=True)
    cutting_id = indexes.CharField(model_attr='cutting_id', indexed=False, stored=True)
    element_id = indexes.CharField(model_attr='element_id', indexed=False, stored=True)
    tags = indexes.CharField(model_attr='tags', stored=True)
    title = indexes.CharField(model_attr='title', stored=True)
    abstract = indexes.CharField(model_attr='abstract', stored=True)
    duration = indexes.IntegerField(model_attr='duration', indexed=False, stored=True)
    author = indexes.CharField(model_attr='author', stored=True, null=True)
    start_ts = indexes.IntegerField(model_attr='start_ts', indexed=False, stored=True)
    date = indexes.CharField(model_attr='date', stored=True)
    
    def get_model(self):
        return Segment
    
class AnnotationIndex(indexes.RealTimeSearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    tags = indexes.CharField(model_attr='tags', indexed=True, stored=False)
    title = indexes.CharField(model_attr='title', indexed=True, stored=True)
    abstract = indexes.CharField(model_attr='description', indexed=True, stored=False)
    text_field = indexes.CharField(model_attr='text', indexed=True, stored=False)
    annotation_id = indexes.CharField(model_attr='extarnal_id', indexed=False, stored=True)

    def get_model(self):
        return Annotation
        