SOLR-18197: Add root document query shortcut support to NestPathField#4512
SOLR-18197: Add root document query shortcut support to NestPathField#4512abumarjikar wants to merge 18 commits into
Conversation
dsmiley
left a comment
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.
dsmiley
left a comment
There was a problem hiding this comment.
still definitely looking for the application of this in the codebase + doc updates
dsmiley
left a comment
There was a problem hiding this comment.
more to do... not ready for my re-review
|
Audit usages of |
|
@dsmiley I audited the usage of
|
|
Thanks. TestNestedUpdateProcessor contains plenty of references to the old confusing syntax that can be updated. Maybe other tests too. |
| "{!parent which='(*:* -_nest_path_:*)'}(+" + inner_child_query + " +_nest_path_:*)"); | ||
| "{!parent which='{!field f=_nest_path_ v=$fieldQ}'}(+" | ||
| + inner_child_query | ||
| + " +_nest_path_:*)", | ||
| "fieldQ", | ||
| "/"); |
There was a problem hiding this comment.
there's irony in you modifying the non-verbose code path .... to make it more verbose. surely you can keep it simple. I'll leave it as a test for you :-)
| "parent_filt", "(*:* -_nest_path_:*)", | ||
| "parent_filt", "{!field f=_nest_path_ v=$fieldQ}", | ||
| "fieldQ", "/", |
There was a problem hiding this comment.
mabye leave the "verbose" codepath as-is.... it should be "verbose" after all :-)
| if (verbose) { | ||
| return params( | ||
| "q", "{!child of=$parent_filt v=$parent_q})", | ||
| "parent_filt", "(*:* -_nest_path_:*)", | ||
| "parent_filt", "{!field f=_nest_path_ v=$fieldQ}", | ||
| "fieldQ", "/", | ||
| "parent_q", "(+" + inner_parent_query + " -_nest_path_:*)"); | ||
| } else { | ||
| return params( | ||
| "q", | ||
| "{!child of='(*:* -_nest_path_:*)'}(+" + inner_parent_query + " -_nest_path_:*)"); | ||
| "{!child of='{!field f=_nest_path_ v=$fieldQ}'}(+" | ||
| + inner_parent_query | ||
| + " -_nest_path_:*)", | ||
| "fieldQ", | ||
| "/"); |
There was a problem hiding this comment.
same critique as down here and below
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.