SOLR-18197: Add root document query shortcut support to NestPathField#4512
Draft
abumarjikar wants to merge 2 commits into
Draft
SOLR-18197: Add root document query shortcut support to NestPathField#4512abumarjikar wants to merge 2 commits into
abumarjikar wants to merge 2 commits into
Conversation
dsmiley
reviewed
Jun 9, 2026
dsmiley
left a comment
Contributor
There was a problem hiding this comment.
Thanks. Looking to see this used widespread in code & docs. The goal is to ensure no user sees that ugly/confusing syntax that was previously necessary.
| @@ -0,0 +1,7 @@ | |||
| title: Add root document query shortcut support to NestPathField | |||
| type: changed | |||
Contributor
There was a problem hiding this comment.
This isn't "changed" since no existing user/query is going to trigger this functionality. The functionality here is opt-in, hence "added". If you think the changelog template could be improved here, LMK.
|
|
||
| @Override | ||
| public Query getFieldQuery(QParser parser, SchemaField field, String externalVal) { | ||
| if (externalVal == null || externalVal.isEmpty() || "/".equals(externalVal)) { |
Contributor
There was a problem hiding this comment.
I'm suspicious of null/empty. Do you think it should be implied the user means only root docs? Maybe we should just throw a SolrException BAD_REQUEST.
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.
https://issues.apache.org/jira/browse/SOLR-18197
Description
This pull request introduces a quick and intuitive shortcut to query root documents within hierarchical/nested data structures using the NestPathField. Currently, finding root-level documents (which do not have a nested path defined) requires a more verbose or explicit query syntax. This change provides a cleaner "ease of use" developer experience when dealing with nested child documents.
Solution
When a query is made against this field with an empty value, a null value, or a root slash ("/"), it automatically constructs and returns a BooleanQuery that targets only top-level root documents. It accomplishes this by matching all documents and explicitly excluding any documents where the nested path field exists:
MUST: MatchAllDocsQuery
MUST_NOT: ExistenceQuery (for the NestPathField)
For all other standard path inputs, it safely falls back to the default super.getFieldQuery(...) behavior.
Tests
Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
Checklist
Please review the following and check all that apply:
mainbranch../gradlew check.