Skip to content
Snippets Groups Projects
Commit 2a9a7b4ef362 authored by Katia Saurfelt's avatar Katia Saurfelt
Browse files

[index] refresh the index after performing the `es_index` operation. (closes #51594388)

If this is not done, elasticsearch.scan method retrieves the old index values
so wrong values will be copied while synchronizing different indexes.

We probably should do it by default in `indexer.es_index` method.
We probably should do it in `indexer.es_delete` method.

see also https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html
parent 49e1524640df
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
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