Skip to content
Snippets Groups Projects
es.py 1.11 KiB
Newer Older
# -*- coding: utf-8 -*-
# copyright 2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr -- mailto:contact@logilab.fr

INDEXABLE_TYPES = None


def index_settings():
    return {'analysis':
            {'analyzer':
             {'default': {'filter': ['standard',
                                     'my_ascii_folding'],
                          'tokenizer': 'standard'}},
             'filter': {'my_ascii_folding': {'preserve_original': True,
                                             'type': 'asciifolding'}}}}


def indexable_types(schema):
    global INDEXABLE_TYPES
    if INDEXABLE_TYPES is not None:
        return INDEXABLE_TYPES
    indexable_types = []
    skip_list = ('TrInfo', 'EmailAddress')
    for eschema in schema.entities():
        if eschema.type in skip_list:
            continue
        if not eschema.final:
            # check eschema.fulltext_relations() ? (skip wf_info_for ?
            # )
            if list(eschema.indexable_attributes()):
                indexable_types.append(eschema.type)
    INDEXABLE_TYPES = indexable_types
    return indexable_types