src/egonomy/search_indexes/indexes.py
author cavaliet
Thu, 27 Jun 2013 17:17:04 +0200
changeset 185 5f265e870a8d
parent 52 eea37d86feea
permissions -rw-r--r--
remove useless data and update integ main.js

# -*- coding: utf-8 -*-
'''
Created on Feb 12, 2013

@author: ymh
'''

from haystack import indexes
from egonomy.models import ImageMetadata
from egonomy.models import Fragment


class ImageMetadataIndex(indexes.SearchIndex, indexes.Indexable):
    
    text = indexes.CharField(document=True, use_template=True)
    
    title = indexes.CharField(model_attr='titre', null=True)
    description = indexes.CharField(model_attr='description', null=True)
    photograph = indexes.CharField(model_attr='photographe', null=True)
    author = indexes.CharField(model_attr='auteur', null=True)
    period = indexes.CharField(model_attr='periode', null=True)
    technic = indexes.CharField(model_attr='technique', null=True)
    site = indexes.CharField(model_attr='site', null=True)
    location = indexes.CharField(model_attr='lieu', null=True)
    localization = indexes.CharField(model_attr='localisation', null=True)
    tags = indexes.CharField(model_attr='mots_cles', null=True)
    
    title_p = indexes.CharField(model_attr="titre_pertimm", null=True)
    description_p = indexes.CharField(model_attr="titre_pertimm", null=True)
    thesaurus_p = indexes.CharField(model_attr="thesaurus_pertimm", null=True)
    
    def get_model(self):
        return ImageMetadata


class FragmentIndex(indexes.SearchIndex, indexes.Indexable):
    
    text = indexes.CharField(document=True, use_template=True)
    
    image = indexes.CharField(model_attr='image', indexed=False, stored=True)
    author = indexes.CharField(model_attr='author', null=True, stored=True)
    title = indexes.CharField(model_attr='title', null=True, stored=True)
    description = indexes.CharField(model_attr='description', null=True, stored=True)
    tags = indexes.CharField(model_attr='tags', null=True, stored=True)
    
    def get_model(self):
        return Fragment