Skip to content

Commit f5624aa

Browse files
ruebrendaarianamiri
ruebrenda
authored andcommitted
Replaced commented code with explanation
1 parent 62007c4 commit f5624aa

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

haystack/backends/elasticsearch_backend.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,11 @@ def update(self, index, iterable, commit=True):
189189

190190
bulk(self.conn, prepped_docs, index=self.index_name, doc_type='modelresult')
191191

192-
# if commit:
193-
# self.conn.indices.refresh(index=self.index_name)
192+
# We are explicitly eliminating the call to self.conn.indices.refresh().
193+
# ElasticSearch will do an automatic refresh once per minute. Manually invoking refresh
194+
# on every update triggers 1000's of unnecessary API calls.
195+
# The underlying issue is that neither SearchIndex.update nor SearchIndex.update_object
196+
# pass kwargs to this method, so setting commit to False does not solve the problem.
194197

195198
def remove(self, obj_or_string, commit=True):
196199
doc_id = get_identifier(obj_or_string)
@@ -209,8 +212,10 @@ def remove(self, obj_or_string, commit=True):
209212
try:
210213
self.conn.delete(index=self.index_name, doc_type='modelresult', id=doc_id, ignore=404)
211214

212-
# if commit:
213-
# self.conn.indices.refresh(index=self.index_name)
215+
# We are explicitly eliminating the call to self.conn.indices.refresh().
216+
# ElasticSearch will do an automatic refresh once per minute. Manually invoking refresh
217+
# on every remove triggers 1000's of unnecessary API calls.
218+
214219
except elasticsearch.TransportError as e:
215220
if not self.silently_fail:
216221
raise

0 commit comments

Comments
 (0)