Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommended way to delete by query? #870

Closed
braunsonm opened this issue Apr 1, 2018 · 3 comments
Closed

Recommended way to delete by query? #870

braunsonm opened this issue Apr 1, 2018 · 3 comments

Comments

@braunsonm
Copy link
Contributor

braunsonm commented Apr 1, 2018

I often have to delete entries which can sometimes exceed 100,000 entries. Thus I have been using:

response = Search().filter('stuff').delete()

But this causes timeout issues elasticsearch.exceptions.ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host='127.0.0.1', port=9200): Read timed out. (read timeout=10))

Is there perhaps a way to let it run and then query every now and then for the status? Just wondering what the usual recommendation is.

@honzakral
Copy link
Contributor

delete_by_query can take quite some time so the recommendation is to either increase the timeout by calling .params(request_timeout=3600) (or some other number higher than 10) to add the parameter to the method call or .params(wait_for_completion=False) to make the api return immediately instead of blocking and waiting.

Hope this helps!

@braunsonm
Copy link
Contributor Author

Thank you very much @honzakral

Is there any reason you'd want to wait for completion? Elasticsearch should get the job done in the background and I can trust that right?

@honzakral
Copy link
Contributor

It should, but there can always be errors if something unexpected happens. You will, however, get a task id back from the initial API call and you can use it later (via the low-level API) to query for the job status/results via the tasks API (0).

0 - https://elasticsearch-py.readthedocs.io/en/master/api.html#tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants