src/ldt/ldt/indexation/search_indexes.py
author ymh <ymh.work@gmail.com>
Thu, 02 Jan 2014 17:47:16 +0100
changeset 1277 622989468114
parent 1275 38c396f3ced8
child 1296 1a24fb79eb11
permissions -rw-r--r--
correct null values
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
1275
38c396f3ced8 Add indexation to content
ymh <ymh.work@gmail.com>
parents: 1117
diff changeset
     9
38c396f3ced8 Add indexation to content
ymh <ymh.work@gmail.com>
parents: 1117
diff changeset
    10
from ldt.ldt_utils.models import Segment, Content
718
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
from ldt.text.models import Annotation
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
1275
38c396f3ced8 Add indexation to content
ymh <ymh.work@gmail.com>
parents: 1117
diff changeset
    13
1117
3bab1e42acfa - update haystack
ymh <ymh.work@gmail.com>
parents: 950
diff changeset
    14
class SegmentIndex(indexes.SearchIndex, indexes.Indexable):
718
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
    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
    16
    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
    17
    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
    18
    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
    19
    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
    20
    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
    21
    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
    22
    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
    23
    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
    24
    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
    25
    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
    26
    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
    27
    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
    28
    
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
    def get_model(self):
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
        return Segment
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
    
1117
3bab1e42acfa - update haystack
ymh <ymh.work@gmail.com>
parents: 950
diff changeset
    32
class AnnotationIndex(indexes.SearchIndex, indexes.Indexable):
718
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
    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
    34
    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
    35
    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
    36
    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
    37
    text_field = indexes.CharField(model_attr='text', indexed=True, stored=False)
950
f08d8b3e78b8 Correct authentication on projects
ymh <ymh.work@gmail.com>
parents: 718
diff changeset
    38
    annotation_id = indexes.CharField(model_attr='external_id', indexed=False, stored=True)
718
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
    def get_model(self):
5e27a39d3742 replace lucene by haystack, remove references to lucene
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
        return Annotation
1275
38c396f3ced8 Add indexation to content
ymh <ymh.work@gmail.com>
parents: 1117
diff changeset
    42
38c396f3ced8 Add indexation to content
ymh <ymh.work@gmail.com>
parents: 1117
diff changeset
    43
38c396f3ced8 Add indexation to content
ymh <ymh.work@gmail.com>
parents: 1117
diff changeset
    44
class ContentIndex(indexes.SearchIndex, indexes.Indexable):
38c396f3ced8 Add indexation to content
ymh <ymh.work@gmail.com>
parents: 1117
diff changeset
    45
    text = indexes.CharField(document=True, use_template=True)
1277
622989468114 correct null values
ymh <ymh.work@gmail.com>
parents: 1275
diff changeset
    46
    tags = indexes.CharField(model_attr='tags', indexed=True, stored=False, null=True)
1275
38c396f3ced8 Add indexation to content
ymh <ymh.work@gmail.com>
parents: 1117
diff changeset
    47
    title = indexes.CharField(model_attr='title', indexed=True, stored=True)
1277
622989468114 correct null values
ymh <ymh.work@gmail.com>
parents: 1275
diff changeset
    48
    abstract = indexes.CharField(model_attr='description', indexed=True, stored=False, null=True)
1275
38c396f3ced8 Add indexation to content
ymh <ymh.work@gmail.com>
parents: 1117
diff changeset
    49
    
38c396f3ced8 Add indexation to content
ymh <ymh.work@gmail.com>
parents: 1117
diff changeset
    50
    def get_model(self):
38c396f3ced8 Add indexation to content
ymh <ymh.work@gmail.com>
parents: 1117
diff changeset
    51
        return Content