# HG changeset patch # User Adrien Di Mascio <Adrien.DiMascio@logilab.fr> # Date 1495631363 -7200 # Wed May 24 15:09:23 2017 +0200 # Node ID 4060fb567a19d20f5a3cd259cc8c726fd4893c72 # Parent 54ec9e5c6291d5062cde78cc86c55e9e00f6ea39 make ES doc_type customizable As for ES "id" parameters, "doc_type" should be customizable, there is no reason why es document type should match cw_etype diff --git a/cubicweb_elasticsearch/entities.py b/cubicweb_elasticsearch/entities.py --- a/cubicweb_elasticsearch/entities.py +++ b/cubicweb_elasticsearch/entities.py @@ -97,6 +97,10 @@ def es_id(self): return self.entity.eid + @property + def es_doc_type(self): + return self.entity.cw_etype + @cachedproperty def fulltext_indexable_attributes(self): eschema = self._cw.vreg.schema[self.entity.cw_etype] diff --git a/cubicweb_elasticsearch/hooks.py b/cubicweb_elasticsearch/hooks.py --- a/cubicweb_elasticsearch/hooks.py +++ b/cubicweb_elasticsearch/hooks.py @@ -99,7 +99,7 @@ # IFullTextIndex serializer, therefore the "id" and "doc_type" in # kwargs below must be container data. kwargs['id'] = serializer.es_id - kwargs['doc_type'] = getattr(serializer, 'doc_type', json['cw_etype']) + kwargs['doc_type'] = serializer.es_doc_type try: # TODO option for async ? es.index(**kwargs)