Skip to content

Add SchemaManager::waitForSearchIndexes()#2830

Merged
GromNaN merged 1 commit intodoctrine:2.13.xfrom
GromNaN:wait-search-index
Sep 30, 2025
Merged

Add SchemaManager::waitForSearchIndexes()#2830
GromNaN merged 1 commit intodoctrine:2.13.xfrom
GromNaN:wait-search-index

Conversation

@GromNaN
Copy link
Member

@GromNaN GromNaN commented Sep 24, 2025

Q A
Type feature
BC Break no
Fixed issues PHPORM-399

Summary

This method waits until all search indexes for specified (or all) document classes are both queryable and have indexed all documents in their corresponding collections.

  • It takes up to three arguments: a list of document class names ($classNames, optional), a maximum wait time in milliseconds ($maxTimeMs, default 10,000 ms), and a delay between checks in milliseconds ($waitTimeMs, default 100 ms).
  • The method validates input arguments, then iterates over the document classes to identify the search indexes that need to be checked.
  • In a loop, it checks whether all required search indexes exist and are marked as queryable.
  • For queryable indexes, it further verifies if all documents have been indexed by comparing the count of indexed documents with the total collection count, using aggregation pipelines appropriate for either 'search' or 'vectorSearch' index types. (removed because unreliable)
  • If not all indexes are ready, it waits for $waitTimeMs before checking again, until either all indexes are ready or the maximum wait time ($maxTimeMs) is exceeded (in which case an exception is thrown).

This addition provides a mechanism for applications to block until search indexes are fully prepared for querying, ensuring consistency and readiness before proceeding with operations that depend on those indexes.

Similar implementation: https://github.com/mongodb-labs/pymongo-search-utils/blob/dddd51f6e1784caa43e0dc66ec8d9487e0762d58/pymongo_search_utils/index.py#L259-L298

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants