Hi I’m trying to use elastic search reindex api via rest high level client and am comparing two ways of doing it.
Rest API:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex-task-api
[![Rest API Documentation screenshot][1]][1]
Running reindex asynchronously - If the request contains wait_for_completion=false, Elasticsearch performs some preflight checks, launches the request, and returns a task you can use to cancel or get the status of the task. Elasticsearch creates a record of this task as a document at _tasks/<task_id>. When you are done with a task, you should delete the task document so Elasticsearch can reclaim the space.
rest high level client:
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-document-reindex.html#java-rest-high-document-reindex-task-submission
[![rest high level client Documentation screenshot][2]][2]
Reindex task submission - It is also possible to submit a ReindexRequest and not wait for it completion with the use of Task API. This is an equivalent of a REST request with wait_for_completion flag set to false.
I’m trying to figure out this: From Rest API Doc I know that I should delete the task document so Elasticsearch can reclaim the space. Since the rest high level client is basically doing the same thing, do I need to “delete the task document” if I choose to use this client instead of the rest API? If so, how can I do that?
Thanks [1]: https://i.stack.imgur.com/OEVHi.png [2]: https://i.stack.imgur.com/sw9Dw.png
Advertisement
Answer
The task document is just a summary of what happen during reindex (so a small document), since you specify to do in async with wait_for_completion=false
it will be created in system indice .tasks
, so you can query this indice like any other to find the summary and delete it.
The .tasks
indice will not be available by default in futur version of Elasticsearch and you will need to use specific function linked to _tasks
with the java REST api available here