5151import org .apache .solr .search .SyntaxError ;
5252import org .apache .solr .util .SolrDefaultScorerSupplier ;
5353
54+ /** Matches parent documents based on child doc criteria. */
5455public class BlockJoinParentQParser extends FiltersQParser {
5556 /** implementation detail subject to change */
5657 public static final String CACHE_NAME = "perSegFilter" ;
@@ -114,8 +115,8 @@ public Query parse() throws SyntaxError {
114115 * <pre>NEW: q={!parent parentPath="/a/b/c"}c_title:son
115116 *
116117 * OLD: q=(+{!field f="_nest_path_" v="/a/b/c"} +{!parent which=$ff v=$vv})
117- * ff=(*:* -{prefix f="_nest_path_" v="/a/b/c/"})
118- * vv=(+c_title:son +{prefix f="_nest_path_" v="/a/b/c/"})</pre>
118+ * ff=(*:* -{! prefix f="_nest_path_" v="/a/b/c/"})
119+ * vv=(+c_title:son +{! prefix f="_nest_path_" v="/a/b/c/"})</pre>
119120 *
120121 * <p>For {@code parentPath="/"}:
121122 *
@@ -129,7 +130,7 @@ public Query parse() throws SyntaxError {
129130 * root "/")
130131 */
131132 protected Query parseUsingParentPath (String parentPath ) throws SyntaxError {
132- // allParents filter: (*:* -{prefix f="_nest_path_" v="<parentPath>/"})
133+ // allParents filter: (*:* -{! prefix f="_nest_path_" v="<parentPath>/"})
133134 // For root: (*:* -_nest_path_:*)
134135 final Query allParentsFilter = buildAllParentsFilterFromPath (parentPath );
135136
@@ -140,15 +141,15 @@ protected Query parseUsingParentPath(String parentPath) throws SyntaxError {
140141 return wrapWithParentPathConstraint (parentPath , allParentsFilter );
141142 }
142143
143- // constrain child query: (+<original_child> +{prefix f="_nest_path_" v="<parentPath>/"})
144+ // constrain child query: (+<original_child> +{! prefix f="_nest_path_" v="<parentPath>/"})
144145 // For root: (+<original_child> +_nest_path_:*)
145146 final Query constrainedChildQuery =
146147 buildChildQueryWithPathConstraint (parentPath , parsedChildQuery );
147148
148149 final String scoreMode = localParams .get ("score" , ScoreMode .None .name ());
149150 final Query parentJoinQuery = createQuery (allParentsFilter , constrainedChildQuery , scoreMode );
150151
151- // wrap result: (+<parent_join> +{field f="_nest_path_" v="<parentPath>"})
152+ // wrap result: (+<parent_join> +{! field f="_nest_path_" v="<parentPath>"})
152153 // For root: (+<parent_join> -_nest_path_:*)
153154 return wrapWithParentPathConstraint (parentPath , parentJoinQuery );
154155 }
@@ -165,7 +166,7 @@ protected Query parseUsingParentPath(String parentPath) throws SyntaxError {
165166 * /a/b/c})
166167 * </ul>
167168 *
168- * <p>Equivalent to: {@code (*:* -{prefix f="_nest_path_" v="<parentPath>/"})} For root ({@code
169+ * <p>Equivalent to: {@code (*:* -{! prefix f="_nest_path_" v="<parentPath>/"})} For root ({@code
169170 * /}): {@code (*:* -_nest_path_:*)}
170171 */
171172 protected static Query buildAllParentsFilterFromPath (String parentPath ) {
@@ -186,7 +187,7 @@ protected static Query buildAllParentsFilterFromPath(String parentPath) {
186187 * level are matched. For root, this excludes docs that have a {@code _nest_path_} value. For
187188 * non-root, this requires an exact match on {@code _nest_path_}.
188189 */
189- private static Query wrapWithParentPathConstraint (String parentPath , Query query ) {
190+ protected static Query wrapWithParentPathConstraint (String parentPath , Query query ) {
190191 final BooleanQuery .Builder builder = new BooleanQuery .Builder ().add (query , Occur .MUST );
191192 if (parentPath .equals ("/" )) {
192193 builder .add (new FieldExistsQuery (IndexSchema .NEST_PATH_FIELD_NAME ), Occur .MUST_NOT );
0 commit comments