snoopdave commented on code in PR #225:
URL: https://github.com/apache/roller/pull/225#discussion_r4419569913


##########
app/src/main/java/org/apache/roller/weblogger/business/search/lucene/SearchOperation.java:
##########
@@ -229,4 +231,71 @@ public void setLocale(String locale) {
         this.locale = locale;
     }
 
+
+    /**
+     * Query parser that accepts explicit field names only for the fields that
+     * searches are meant to cover. Other index fields hold data that is not
+     * shown on the weblog, so a query naming one is a parse error.
+     */
+    static class SearchFieldsQueryParser extends MultiFieldQueryParser {

Review Comment:
   This works only if we override every method that builds a field query. A 
Lucene upgrade that adds one would quietly undo the restriction. Lucene 9.12 
has `Query.visit(QueryVisitor)`: parse normally, then walk the query and refuse 
any field not in `SEARCH_FIELDS` (`consumeTerms` for terms, `acceptField` for 
wildcard, prefix, regexp and range). `*:*` is a `MatchAllDocsQuery` with no 
field, so no special case. About 15 lines instead of 7 overrides, and it covers 
any query type.
   



-- 
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]

Reply via email to