dsmiley opened a new pull request, #5391: URL: https://github.com/apache/solr/pull/5391
https://issues.apache.org/jira/browse/SOLR-18199 # Description Delete-by-query (DBQ) with nested documents could easily leave orphaned child documents: unless the query also matched every descendant of what it deleted, nested-doc integrity was violated. # Solution When the schema has `_nest_path_`, `DirectUpdateHandler2.getQuery()` wraps the DBQ in a new `WithDescendantsQuery`, which also matches all nested descendants of the matched docs, at any depth. Because only the query string is logged and forwarded, expanding it there applies consistently on every replica, to reordered DBQs, and on tlog replay. `*:*` is left alone. Opt out with the `withDescendants=false` local param, e.g. `{!lucene withDescendants=false}...`. `WithDescendantsQuery` relies on descendants being indexed immediately before their ancestor. When all matches in a segment are roots (the common case), it uses the cached roots filter shared with `{!parent which=/}`. Otherwise it works level by level from the `_nest_path_` terms. See its javadocs for details. A small `FixedBitSetIntersectionIterator` utility was added for that. Notes: * Docs without a nest path (anonymous children, or docs indexed before `_nest_path_` was added) aren't found as descendants; documented. * The roots filter is obtained without the request's searcher, since some `UpdateLog` requests are never closed (a pre-existing leak risk for any DBQ parser that calls `req.getSearcher()`). * Fixed `SolrTestCaseJ4.json()`, which wrote child docs in a list twice. # Tests * `WithDescendantsQueryTest`: randomized multi-level trees across segments vs. a reference model, plus Lucene's `QueryUtils.check` * `DeleteByQueryNestedDocsTest`: randomized DBQ shapes vs. a model, opt-out, and a `_root_`-only schema * `TestRecovery`: reordered DBQs with tlog replay * `DeleteByQueryNestedDocsCloudTest`: replicas stay consistent * `FixedBitSetIntersectionIteratorTest` # Checklist - [x] I have reviewed the guidelines for [How to Contribute](https://github.com/apache/solr/blob/main/CONTRIBUTING.md) and my code conforms to the standards described there to the best of my ability. - [x] I have created a Jira issue and added the issue ID to my pull request title. - [x] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation) - [x] I have developed this patch against the `main` branch. - [x] I have run `./gradlew check`. - [x] I have added tests for my changes. - [x] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide) - [x] I have added a [changelog entry](https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc) for my change 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
