Skip to content
Snippets Groups Projects
Commit d0bef20eb4a8 authored by Adrien Di Mascio's avatar Adrien Di Mascio
Browse files

[es] settings must be "deep-updated" with custom ones

Otherwise we would overwrite the "mappings" entry
parent 235988caf139
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-elasticsearch entity's classes""" """cubicweb-elasticsearch entity's classes"""
import collections
from cubicweb import view from cubicweb import view
from cubicweb.predicates import is_instance from cubicweb.predicates import is_instance
...@@ -24,6 +27,15 @@ ...@@ -24,6 +27,15 @@
from cubes.elasticsearch import es from cubes.elasticsearch import es
def deep_update(d1, d2):
for key, value in d2.iteritems():
if isinstance(value, collections.Mapping):
d1[key] = deep_update(d1.get(key, {}), value)
else:
d1[key] = d2[key]
return d1
class EsRegistry(AppObject): class EsRegistry(AppObject):
__registry__ = 'es' __registry__ = 'es'
...@@ -55,8 +67,8 @@ ...@@ -55,8 +67,8 @@
settings = self.settings settings = self.settings
else: else:
settings = {} settings = {}
settings.update(self.settings) deep_update(settings, self.settings)
settings.update(custom_settings) deep_update(settings, custom_settings)
es.create_index(self.get_connection(), index_name, settings) es.create_index(self.get_connection(), index_name, settings)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment