from django.template.loader import render_to_string from django_elasticsearch_dsl import Document, fields from django_elasticsearch_dsl.registries import registry from froide.helper.search import (get_index, get_text_analyzer, get_search_analyzer, get_search_quote_analyzer) from .models import FoiRequest index = get_index('foirequest') analyzer = get_text_analyzer() search_analyzer = get_search_analyzer() search_quote_analyzer = get_search_quote_analyzer() @registry.register_document @index.document class FoiRequestDocument(Document): content = fields.TextField(analyzer=analyzer, search_analyzer=search_analyzer, search_quote_analyzer=search_quote_analyzer, index_options='offsets') title = fields.TextField() description = fields.TextField() resolution = fields.KeywordField() status = fields.KeywordField() costs = fields.FloatField()
from django.utils.html import strip_tags from django_elasticsearch_dsl import DocType, fields from froide.helper.search import ( get_index, get_text_analyzer ) from froide.helper.tasks import ( search_instance_save, search_instance_delete ) from .models import Article index = get_index('article') analyzer = get_text_analyzer() @index.doc_type class ArticleDocument(DocType): title = fields.TextField( fields={'raw': fields.KeywordField()}, analyzer=analyzer, ) url = fields.TextField( fields={'raw': fields.KeywordField()}, analyzer=analyzer, ) description = fields.TextField(
from django_elasticsearch_dsl import DocType, fields from froide.helper.search import (get_index, get_text_analyzer, get_ngram_analyzer) from .models import PublicBody index = get_index('publicbody') analyzer = get_text_analyzer() ngram_analyzer = get_ngram_analyzer() @index.doc_type class PublicBodyDocument(DocType): name = fields.TextField( fields={'raw': fields.KeywordField()}, analyzer=analyzer, ) name_auto = fields.TextField(attr='all_names', analyzer=ngram_analyzer) content = fields.TextField(analyzer=analyzer) jurisdiction = fields.IntegerField(attr='jurisdiction_id') classification = fields.ListField(fields.IntegerField()) categories = fields.ListField(fields.IntegerField()) class Meta: model = PublicBody queryset_chunk_size = 100 def get_queryset(self):
from django_elasticsearch_dsl import DocType, fields from froide.helper.search import (get_index, get_text_analyzer, get_search_analyzer, get_search_quote_analyzer) from filingcabinet.models import Page index = get_index('documentpage') analyzer = get_text_analyzer() search_analyzer = get_search_analyzer() search_quote_analyzer = get_search_quote_analyzer() @index.doc_type class PageDocument(DocType): document = fields.IntegerField(attr='document_id') title = fields.TextField() description = fields.TextField() tags = fields.ListField(fields.KeywordField()) created_at = fields.DateField() publicbody = fields.IntegerField(attr='document.publicbody_id') jurisdiction = fields.IntegerField( attr='document.publicbody.jurisdiction_id') foirequest = fields.IntegerField(attr='document.foirequest_id') campaign = fields.IntegerField(attr='document.foirequest.campaign_id') collections = fields.IntegerField()
from django_elasticsearch_dsl import DocType, fields from froide.helper.search import ( get_index, get_text_analyzer, get_ngram_analyzer ) from .models import PublicBody index = get_index('publicbody') analyzer = get_text_analyzer() ngram_analyzer = get_ngram_analyzer() @index.doc_type class PublicBodyDocument(DocType): name = fields.TextField( fields={'raw': fields.KeywordField()}, analyzer=analyzer, ) name_auto = fields.TextField( attr='all_names', analyzer=ngram_analyzer ) content = fields.TextField( analyzer=analyzer ) jurisdiction = fields.IntegerField(attr='jurisdiction_id') classification = fields.ListField(fields.IntegerField())
from django_elasticsearch_dsl import DocType, fields from django.template.loader import render_to_string from froide.helper.search import get_index, get_text_analyzer from .models import FoiRequest index = get_index('foirequest') analyzer = get_text_analyzer() @index.doc_type class FoiRequestDocument(DocType): content = fields.TextField( analyzer=analyzer, index_options='offsets' ) title = fields.TextField() description = fields.TextField() resolution = fields.KeywordField() status = fields.KeywordField() costs = fields.FloatField() tags = fields.ListField(fields.KeywordField()) classification = fields.ListField(fields.IntegerField()) categories = fields.ListField(fields.IntegerField()) campaign = fields.IntegerField() due_date = fields.DateField()
from django_elasticsearch_dsl.registries import registry from cms.models import Title from sekizai.context import SekizaiContext from froide.helper.search import ( get_index, get_text_analyzer, get_search_analyzer, get_search_quote_analyzer, ) from .utils import render_placeholder, clean_join, get_request index = get_index("cmspage") analyzer = get_text_analyzer() search_analyzer = get_search_analyzer() search_quote_analyzer = get_search_quote_analyzer() @registry.register_document @index.document class CMSDocument(Document): title = fields.TextField( fields={"raw": fields.KeywordField()}, analyzer=analyzer, ) url = fields.TextField( fields={"raw": fields.KeywordField()},
from django.utils.html import strip_tags from django_elasticsearch_dsl import DocType, fields from cms.models import Title from froide.helper.search import ( get_index, get_text_analyzer ) from .utils import ( render_placeholder, clean_join, get_request ) index = get_index('cmspage') analyzer = get_text_analyzer() @index.doc_type class CMSDocument(DocType): title = fields.TextField( fields={'raw': fields.KeywordField()}, analyzer=analyzer, ) url = fields.TextField( fields={'raw': fields.KeywordField()}, analyzer=analyzer, ) description = fields.TextField(
Adapted from https://github.com/divio/aldryn-search/blob/master/aldryn_search/search_indexes.py ''' from django.utils.html import strip_tags from django_elasticsearch_dsl import DocType, fields from froide.helper.search import ( get_index, get_text_analyzer ) from .models import Article index = get_index('article') analyzer = get_text_analyzer() @index.doc_type class ArticleDocument(DocType): title = fields.TextField( fields={'raw': fields.KeywordField()}, analyzer=analyzer, ) url = fields.TextField( fields={'raw': fields.KeywordField()}, analyzer=analyzer, ) description = fields.TextField(