# HG changeset patch # User Arthur Lutz <arthur.lutz@logilab.fr> # Date 1463580165 -7200 # Wed May 18 16:02:45 2016 +0200 # Node ID 67b13eecf542a9e12b5d2332701190d9afc555ff # Parent 70fdf9d3b4248d8a16a514f63f41e7b57471bcd5 [es.py] small library to compute indexable types diff --git a/es.py b/es.py new file mode 100644 --- /dev/null +++ b/es.py @@ -0,0 +1,33 @@ +# -*- 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