Пример #1
0
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(
        fields={'raw': fields.KeywordField()},
        analyzer=analyzer,
Пример #2
0
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())