We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When using save_objects() to add items to an index, I can't find a way to wait for the indexing to complete. I tried:
save_objects()
.wait()
wait_for_task()
But the neither of them worked.
from algoliasearch.search.client import SearchClientSync algolia_client = SearchClientSync(ALGOLIA_APP_ID, ALGOLIA_ADMIN_KEY) # Upload items to Algolia index save_resp = algolia_client.save_objects(ALGOLIA_INDEX_NAME, new_items) # also tried .wait() here # Tried this approach but getting error that wait_for_task() does not exist algolia_client.wait_for_task( index_name=ALGOLIA_INDEX_NAME, task_id=save_resp.task_id )``` ## Expected behavior - After calling `wait()` or `wait_for_task()`, the program should await until the indexing is finished - There should be a clear way to wait for indexing to complete ## Questions 1. What is the correct way to wait for objects to be fully indexed? 2. Is there any documentation about this? The ones i found were not helpful but rather a bit confusing. ### Client Crawler ### Version 4.6.5 ### Relevant log output _No response_
The text was updated successfully, but these errors were encountered:
Hey there, we have actually an option internally to wait in those helpers, it will be exposed after this PR algolia/api-clients-automation#4030
In the meantime, the below snippet to wait after a save_objects call should work with the latest version
save_objects
from os import environ from algoliasearch.search.client import SearchClientSync from algoliasearch.search import __version__ def main(): print("SearchClient version", __version__) client = SearchClientSync(environ.get("ALGOLIA_APPLICATION_ID"), environ.get("ALGOLIA_API_KEY")) print("client initialized", client) try: resp = client.save_objects("foo", [{"foo": "bar"}]) print(resp) for r in resp: client.wait_for_task(index_name="foo", task_id=r.task_id) finally: client.close() print("client closed") main()
Notice that save_objects returns a list of responses, since we chunk the given objects to make sure it fits in the request made to the API
objects
Sorry, something went wrong.
Well, solutions not always need to be hard. 😄 Perfect, thanks a lot!
shortcuts
Successfully merging a pull request may close this issue.
Description
When using
save_objects()
to add items to an index, I can't find a way to wait for the indexing to complete. I tried:.wait()
wait_for_task()
But the neither of them worked.
Example code
The text was updated successfully, but these errors were encountered: