opensearch-project / opensearch-py

Python Client for OpenSearch
https://opensearch.org/docs/latest/clients/python/
Apache License 2.0
338 stars 170 forks source link

[FEATURE] forcemerge should support wait_for_completion #737

Closed prabhupant closed 5 months ago

prabhupant commented 5 months ago

Let me know if this proposal makes sense

Is your feature request related to a problem?

forcemerge operation is quite heavy and esp if there is a large index, this operation is bound to take time. Currently, like reindex API this does not support passing wait_for_completion parameter, so there is no way to know whether the job succeeded. As we are developing scripts to maintain the index, tracking the job using the task ID will help us keep track of the job.

What solution would you like?

Add wait_for_completion query parameter which will return the task ID

What alternatives have you considered?

Currently the only alternative, I think, is to query the index stats after force refresh and compare the stats

dblock commented 5 months ago

@prabhupant Do you have a moment to contribute this?

I see it in https://github.com/opensearch-project/opensearch-api-specification/blob/eb271e654015250b924b6e3c2f1ad0865333a19d/spec/namespaces/indices.yaml#L1275, so I imagine our generator doesn't handle these parameters? cc: @saimedhi

saimedhi commented 5 months ago

@dblock, @prabhupant, the opensearch-py client includes a wait_for_completion parameter in the forcemerge API. You can view it here. Let me know if I missed anything. Thanks!

dblock commented 5 months ago

@prabhupant Maybe you're using an old version of the client? Can we close this?

prabhupant commented 5 months ago

@saimedhi @dblock Thanks for pointing it out! I had an older version of the client and it wasn't available there.

Also, just one more question. I see in the OpenSearch API docs that forcemerge doesn't have wait_for_completion in query param https://opensearch.org/docs/latest/api-reference/index-apis/force-merge/#query-parameters. Using this in the request does not return a task ID like it does for reindex. Let me know if my query is wrong

Screenshot 2024-05-01 at 6 36 38 AM
dblock commented 5 months ago

Also, just one more question. I see in the OpenSearch API docs that forcemerge doesn't have wait_for_completion in query param https://opensearch.org/docs/latest/api-reference/index-apis/force-merge/#query-parameters. Using this in the request does not return a task ID like it does for reindex. Let me know if my query is wrong

I am not too familiar with this feature, I would do a couple of things:

  1. If there's a clear gap in documentation (this feature exists, not documented?) either contribute the doc change to https://github.com/opensearch-project/documentation-website or at least open an issue.
  2. If the feature is not behaving in a way you expect, open an issue with details in https://github.com/opensearch-project/OpenSearch. Try to explain what you get (a curl example) and what you expect to get back.