src/ldt/ldt/indexation/search_indexes.py
author cavaliet
Tue, 06 Nov 2012 13:56:54 +0100
changeset 895 e76df6d34e6f
parent 718 5e27a39d3742
child 950 f08d8b3e78b8
permissions -rw-r--r--
Merge with bd5f9dea97910caae6c2fb1ef8fc2e119e47d248
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
718
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
# -*- coding: utf-8 -*-
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
'''
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
Created on Jul 23, 2012
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
@author: ymh
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
'''
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
from haystack import indexes
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
from ldt.ldt_utils.models import Segment 
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
from ldt.text.models import Annotation
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
class SegmentIndex(indexes.RealTimeSearchIndex, indexes.Indexable):
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
    text = indexes.CharField(document=True, use_template=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
    iri_id = indexes.CharField(model_attr='iri_id', indexed=False, stored=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
    project_id = indexes.CharField(model_attr='project_id', indexed=False, stored=True, null=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
    ensemble_id = indexes.CharField(model_attr='ensemble_id', indexed=False, stored=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
    cutting_id = indexes.CharField(model_attr='cutting_id', indexed=False, stored=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
    element_id = indexes.CharField(model_attr='element_id', indexed=False, stored=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
    tags = indexes.CharField(model_attr='tags', stored=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
    title = indexes.CharField(model_attr='title', stored=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
    abstract = indexes.CharField(model_attr='abstract', stored=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
    duration = indexes.IntegerField(model_attr='duration', indexed=False, stored=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
    author = indexes.CharField(model_attr='author', stored=True, null=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
    start_ts = indexes.IntegerField(model_attr='start_ts', indexed=False, stored=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
    date = indexes.CharField(model_attr='date', stored=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
    
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
    def get_model(self):
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
        return Segment
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
    
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
class AnnotationIndex(indexes.RealTimeSearchIndex, indexes.Indexable):
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
    text = indexes.CharField(document=True, use_template=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
    tags = indexes.CharField(model_attr='tags', indexed=True, stored=False)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
    title = indexes.CharField(model_attr='title', indexed=True, stored=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
    abstract = indexes.CharField(model_attr='description', indexed=True, stored=False)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
    text_field = indexes.CharField(model_attr='text', indexed=True, stored=False)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
    annotation_id = indexes.CharField(model_attr='extarnal_id', indexed=False, stored=True)
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
    def get_model(self):
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
        return Annotation
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40