diff --git a/cubicweb_elasticsearch/entities.py b/cubicweb_elasticsearch/entities.py index 49e1524640dfa23bd05aef4ad690d3757e2018d2_Y3ViaWN3ZWJfZWxhc3RpY3NlYXJjaC9lbnRpdGllcy5weQ==..2a9a7b4ef36297970604c6e1adbc7a15f62ad853_Y3ViaWN3ZWJfZWxhc3RpY3NlYXJjaC9lbnRpdGllcy5weQ== 100644 --- a/cubicweb_elasticsearch/entities.py +++ b/cubicweb_elasticsearch/entities.py @@ -19,6 +19,8 @@ import collections +from functools import partial + from urllib3.exceptions import ProtocolError from elasticsearch.exceptions import ConnectionError, NotFoundError @@ -86,7 +88,7 @@ if es_cnx is not None: es.create_index(es_cnx, index_name, settings) - def es_index(self, entity): + def es_index(self, entity, params=None): es_cnx = self.get_connection() if es_cnx is None or not self.index_name: self.error('no connection to ES (not configured) skip ES indexing') @@ -96,7 +98,8 @@ if not json: return es_cnx.index(index=self.index_name, id=serializable.es_id, - doc_type=serializable.es_doc_type, body=json) + doc_type=serializable.es_doc_type, body=json, + params=params) def es_delete(self, entity): es_cnx = self.get_connection() @@ -218,7 +221,7 @@ if self._cw.deleted_in_transaction(entity.eid): es_method = indexer.es_delete elif es_operation['op_type'] == 'index': - es_method = indexer.es_index + es_method = partial(indexer.es_index, params={'refresh': True}) elif es_operation['op_type'] == 'delete': es_method = indexer.es_delete else: