Repository navigation
Conversation
Register a callable via ClientManager::setResolver() / Index::setClientResolver() that builds the ES client on first get(), memoized per connection. Defers construction for runtime-context clients and long-lived workers without changing the static registration API; set()/setResolver() are mutually exclusive per connection (last write wins). Update README and docs examples to register via resolver. Co-Authored-By: Claude <noreply@anthropic.com>
…es trait Agg and Node had byte-identical resolveProperties logic. Move it to a shared trait so Agg stays independent of Node and Query/Intervals/ FunctionScore still inherit it via Node.
…ailure A lost response can leave the swap outcome ambiguous: updateAliases may have been applied server-side while the client still sees an exception. The old cleanup deleted the new index unconditionally, which in that window destroys the index the alias just switched to (dangling alias, lost writes, rollback() unusable). Now the swap catch checks getAlias first: keep the new index when it is already aliased or the state cannot be verified (operator resolves via rollback()/clean()), delete only when the alias verifiably does not point to it. Cleanup deletes no longer mask the original exception. Co-Authored-By: Claude <noreply@anthropic.com>
_count only accepts a query in its body, so any chained search param (size, sort, aggs, ...) made ES reject the request with 400. Extract the query from the built body instead of sending it whole, omit the body when there are no clauses, and include urlParams (routing) like doSearch does. Co-Authored-By: Claude <noreply@anthropic.com>
Two fixes had each grown its own ClientInterface double. Consolidate into tests/Support (FakeClient + FakeIndicesNamespace + FakeResult): call recording, per-endpoint outcome queues, and Throwable scripting. Unit tests may now cover client interaction (request shape, unreproducible failure paths) without re-rolling this infrastructure. Co-Authored-By: Claude <noreply@anthropic.com>
SearchCountTest -> SearchTest, RebuildCleanupTest -> RebuildTest, matching the one-class-per-file taxonomy of the unit suite. Upcoming Search fixes (doSearch pollution, cursor keys) land in the same files. Co-Authored-By: Claude <noreply@anthropic.com>
…query doSearch wrote the index's track_total_hits default back into the shared Query, so reusing a Search leaked it into later calls: scroll() after get() sent track_total_hits=false and ES rejected the scroll (400), and an explicit track_total_hits=true in a raw body was silently overridden because hasParam() only sees chained params. Merge the default into the request body only, checking the final body (covers both chained params and raw bodies). The same hasParam blind spot made scroll()'s size default override a raw-body size with 1000 — check the final body there too. hasParam() keeps its chained-only semantics. Co-Authored-By: Claude <noreply@anthropic.com>
With an int track_total_hits cap, ES reports hits.total as a lower bound (relation "gte"). hasMorePages() compared page against lastPage() computed from that bound, so the page at the cap boundary reported no more pages even when data continued — violating its contract as a next-page signal. Trust a gte total only to prove pages below the bound exist; at or past it, fall back to the full-page heuristic already used when the total is absent. lastPage() keeps returning the bound-derived estimate, matching the earlier decision that capped totals feed pagination as-is. Co-Authored-By: Claude <noreply@anthropic.com>
yield from preserved each scroll batch's 0-based keys, so flattening with iterator_to_array() — which preserves keys by default — silently dropped all but the last batch. Yield each hit individually to assign continuous keys across the whole generator. Co-Authored-By: Claude <noreply@anthropic.com>
The example showed two consecutive $q->bool() calls, which are sibling clauses under one query key and throw on serialization. Append within a single bool instead, and state the sibling-clause rule explicitly. Pin the throwing behavior with a test so the docs cannot drift again. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Six fixes from an external review of
8.0.0, plus shared unit-test infrastructure.Rebuild's failure cleanup deleted the new index unconditionally — ifupdateAliaseswas applied but its response was lost, that destroyed the index the alias had just switched to (dangling alias, lost writes). The swap catch now verifies the alias first and keeps the new index when the swap may have landed or the state cannot be checked; verified orphans are still removed, and cleanup failures no longer mask the original exception.count()sent the whole search body to_count, which accepts a query only — any chained param (size,sort,aggs, ...) got a 400. The body is now projected down to the query (omitted when empty) androuting()is carried.doSearch()wrote the index'strack_total_hitsdefault back into the sharedQuery, soget()thenscroll()on oneSearchsent a disabled total into a scroll context (ES rejects it, 400) and an explicittrack_total_hits: truein a raw body was silently overridden. Defaults now merge into the request only. The same blind spot madescroll()'s batch-size default override a raw-bodysize— fixed alike.trackTotalHitscap,hasMorePages()treated the lower-bound total (relation: gte) as exact and stopped pagination at the cap boundary. A gte total now only proves pages below it exist; at or past the bound the full-page heuristic applies.lastPage()keeps the bound-derived estimate, matching the earlier capped-total decision.cursor()kept each scroll batch's 0-based keys, soiterator_to_array($search->cursor())dropped all but the last batch. Hits now yield with continuous keys.bool()calls — sibling clauses under onequerykey, which throw on serialize. Now appends inside a singlebool; the throwing behavior is pinned by a test.Search/Rebuildrequest shape and failure paths, backed by sharedtests/Support/FakeClientdoubles (recorded calls, scripted responses); test files follow the per-class taxonomy.Behavior note:
search.query.before/afterevents withaction=countnow carry the query-only body indslinstead of the full (rejected) search body.🤖 Generated with Claude Code