0

I am using elasticsearch-dsl python library with my python code. I was trying to update the document, so to avoid the concurrency race conditions i need to acquire and free lock on a document. How to do this using this library. I have already gone through it's documentation but didn't find anything to do that.

Nipun Garg
  • 125
  • 6

1 Answers1

0

The proper way to avoid concurrency issues with elasticsearch is not locking but instead using the version metadata ([0]). To do that simply make sure that the document contains the proper version in its .meta dictionary. this is done by default if the document has been retrieved using the get API or when specifying .extra(version=True) on the Search object ([1]).

0 - https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#_parameters_2 1 - https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-version.html

Honza Král
  • 2,982
  • 14
  • 11