dsmiley commented on code in PR #5377:
URL: https://github.com/apache/solr/pull/5377#discussion_r4656353688
##########
solr/core/src/java/org/apache/solr/search/QueryUtils.java:
##########
@@ -181,33 +179,54 @@ public static Query getAbs(Query q) {
}
}
- /** Makes negative queries suitable for querying by lucene. */
+ /**
+ * Unwraps {@link WrappedQuery} and also fixes negative queries. The
WrappedQuery's cache/cost
+ * hints are dropped; they only matter at the root of the final query, which
{@link
+ * QParser#getQuery()} handles. Suitable for a query parser or right before
a query is processed
+ * by {@link SolrIndexSearcher} or other low-level plumbing.
+ */
public static Query makeQueryable(Query q) {
- if (q instanceof WrappedQuery) {
- return makeQueryable(((WrappedQuery) q).getWrappedQuery());
- }
- return isNegative(q) ? fixNegativeQuery(q) : q;
+ return switch (q) {
+ case WrappedQuery wq -> makeQueryable(wq.getWrappedQuery()); // recursion
+ case BooleanQuery bq -> fixNegativeQuery(bq);
+ default -> q;
+ };
}
- /**
- * Fixes a negative query by adding a MatchAllDocs query clause. The query
passed in *must* be a
- * negative query.
- */
+ /** Fixes a negative query by adding a MatchAllDocs query clause. */
+ @Deprecated(since = "10.2") // weird
Review Comment:
easy to accidentally call without reading the fine print -- assumes it's
already negative. Weird.
##########
solr/core/src/java/org/apache/solr/search/QueryUtils.java:
##########
@@ -181,33 +179,54 @@ public static Query getAbs(Query q) {
}
}
- /** Makes negative queries suitable for querying by lucene. */
+ /**
+ * Unwraps {@link WrappedQuery} and also fixes negative queries. The
WrappedQuery's cache/cost
+ * hints are dropped; they only matter at the root of the final query, which
{@link
+ * QParser#getQuery()} handles. Suitable for a query parser or right before
a query is processed
+ * by {@link SolrIndexSearcher} or other low-level plumbing.
+ */
public static Query makeQueryable(Query q) {
- if (q instanceof WrappedQuery) {
- return makeQueryable(((WrappedQuery) q).getWrappedQuery());
- }
- return isNegative(q) ? fixNegativeQuery(q) : q;
+ return switch (q) {
+ case WrappedQuery wq -> makeQueryable(wq.getWrappedQuery()); // recursion
+ case BooleanQuery bq -> fixNegativeQuery(bq);
+ default -> q;
+ };
}
- /**
- * Fixes a negative query by adding a MatchAllDocs query clause. The query
passed in *must* be a
- * negative query.
- */
+ /** Fixes a negative query by adding a MatchAllDocs query clause. */
+ @Deprecated(since = "10.2") // weird
Review Comment:
Not to mention the needless BoostQuery
--
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]