src/hdabo/search_indexes.py
author rougeronj
Tue, 10 Mar 2015 15:25:18 +0100
changeset 527 27e94248c5f5
parent 266 825ff4d6a8ac
permissions -rw-r--r--
change "disciplines" to "domaines" and add translations
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11
143ab88d17f8 add ordered manytomany fields and indexing
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
'''
143ab88d17f8 add ordered manytomany fields and indexing
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
Created on May 30, 2011
143ab88d17f8 add ordered manytomany fields and indexing
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
143ab88d17f8 add ordered manytomany fields and indexing
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
@author: ymh
143ab88d17f8 add ordered manytomany fields and indexing
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
'''
143ab88d17f8 add ordered manytomany fields and indexing
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
266
825ff4d6a8ac reorganise folders and update venv dependancies (django, etc...)
cavaliet
parents: 21
diff changeset
     7
#from haystack import site
825ff4d6a8ac reorganise folders and update venv dependancies (django, etc...)
cavaliet
parents: 21
diff changeset
     8
#from haystack.indexes import SearchIndex, CharField
825ff4d6a8ac reorganise folders and update venv dependancies (django, etc...)
cavaliet
parents: 21
diff changeset
     9
from haystack import indexes
11
143ab88d17f8 add ordered manytomany fields and indexing
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
from hdabo.models import Datasheet
143ab88d17f8 add ordered manytomany fields and indexing
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
266
825ff4d6a8ac reorganise folders and update venv dependancies (django, etc...)
cavaliet
parents: 21
diff changeset
    12
class DatasheetIndex(indexes.SearchIndex, indexes.Indexable):
11
143ab88d17f8 add ordered manytomany fields and indexing
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
    '''
143ab88d17f8 add ordered manytomany fields and indexing
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
    The search index for the datasheet
143ab88d17f8 add ordered manytomany fields and indexing
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
    '''
266
825ff4d6a8ac reorganise folders and update venv dependancies (django, etc...)
cavaliet
parents: 21
diff changeset
    16
    text = indexes.CharField(document=True, use_template=True)
825ff4d6a8ac reorganise folders and update venv dependancies (django, etc...)
cavaliet
parents: 21
diff changeset
    17
    hda_id = indexes.CharField(model_attr='hda_id', indexed=True, stored=True)
825ff4d6a8ac reorganise folders and update venv dependancies (django, etc...)
cavaliet
parents: 21
diff changeset
    18
    title = indexes.CharField(model_attr='title', indexed=True, stored=True, boost=2.0)
825ff4d6a8ac reorganise folders and update venv dependancies (django, etc...)
cavaliet
parents: 21
diff changeset
    19
    description = indexes.CharField(model_attr='description', indexed=True, stored=True, boost=1.0)
11
143ab88d17f8 add ordered manytomany fields and indexing
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
    
266
825ff4d6a8ac reorganise folders and update venv dependancies (django, etc...)
cavaliet
parents: 21
diff changeset
    21
    def get_model(self):
825ff4d6a8ac reorganise folders and update venv dependancies (django, etc...)
cavaliet
parents: 21
diff changeset
    22
        return Datasheet
11
143ab88d17f8 add ordered manytomany fields and indexing
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
266
825ff4d6a8ac reorganise folders and update venv dependancies (django, etc...)
cavaliet
parents: 21
diff changeset
    24
#site.register(Datasheet, DatasheetIndex)