# HG changeset patch # User Arthur Lutz <arthur.lutz@logilab.fr> # Date 1464954042 -7200 # Fri Jun 03 13:40:42 2016 +0200 # Node ID 4cc49ddcc09455e6f391b0bcf0d1aa4b15dd61db # Parent fce27a9be2dcbac066e93f4d5e60ca24cb823ece index configuration to global variable so it can be modified from another cube diff --git a/ccplugin.py b/ccplugin.py --- a/ccplugin.py +++ b/ccplugin.py @@ -16,7 +16,7 @@ from cubicweb.utils import admincnx from cubicweb.toolsutils import Command -from cubes.elasticsearch.es import indexable_types, index_settings +from cubes.elasticsearch.es import indexable_types, INDEX_SETTINGS __docformat__ = "restructuredtext en" @@ -69,7 +69,7 @@ # ignore 400 caused by IndexAlreadyExistsException when creating an # index es.indices.create( - index=index_name, body=index_settings(), ignore=400) + index=index_name, body=INDEX_SETTINGS, ignore=400) if self.config.debug: print(u'found indexable_types {}'.format( diff --git a/es.py b/es.py --- a/es.py +++ b/es.py @@ -18,8 +18,7 @@ INDEXABLE_TYPES = None -def index_settings(): - return {'analysis': +INDEX_SETTINGS = {'analysis': {'analyzer': {'default': {'filter': ['standard', 'my_ascii_folding', @@ -32,17 +31,6 @@ 'language': 'French'} } }, - "mappings": { - "Did": { - "properties": { - "unitid": { - "type": "string", - "index": "not_analyzed" - } - } - } - } - } diff --git a/hooks.py b/hooks.py --- a/hooks.py +++ b/hooks.py @@ -25,7 +25,7 @@ from cubicweb.server import hook from cubicweb.predicates import score_entity -from cubes.elasticsearch.es import indexable_types +from cubes.elasticsearch.es import indexable_types, INDEX_SETTINGS log = logging.getLogger(__name__) diff --git a/test/test_elastic_search.py b/test/test_elastic_search.py --- a/test/test_elastic_search.py +++ b/test/test_elastic_search.py @@ -13,7 +13,7 @@ from cubicweb.devtools import testlib from cubicweb.cwconfig import CubicWebConfiguration from cubes.elasticsearch import ccplugin -from cubes.elasticsearch.es import indexable_types, index_settings +from cubes.elasticsearch.es import indexable_types, INDEX_SETTINGS class ExportElasticSearchTC(testlib.AutoPopulateTest): @@ -82,7 +82,7 @@ self.assert_(cnx.execute('Any X WHERE X is %(etype)s' % {'etype': indexable_types(cnx.repo)[0]})) create.assert_called_with( - ignore=400, index='unittest_index_name', body=index_settings()) + ignore=400, index='unittest_index_name', body=INDEX_SETTINGS) index.assert_called() # TODO ? check called data