vismaytiwari commented on code in PR #16382:
URL: https://github.com/apache/lucene/pull/16382#discussion_r3564876956


##########
lucene/core/src/java/org/apache/lucene/search/WildcardQuery.java:
##########
@@ -74,22 +73,27 @@ public static Automaton toAutomaton(Term wildcardquery) {
       final int c = wildcardText.codePointAt(i);
       int length = Character.charCount(c);
       switch (c) {
-        case WILDCARD_STRING:
-          automata.add(Automata.makeAnyString());
-          break;
-        case WILDCARD_CHAR:
-          automata.add(Automata.makeAnyChar());
-          break;
-        case WILDCARD_ESCAPE:
-          // add the next codepoint instead, if it exists
+        case WILDCARD_STRING -> {
+          // Collapse consecutive '*' ("**" is equivalent to "*"): only append 
an
+          // any-string automaton when the previous segment isn't already one.
+          if (automata.isEmpty()
+              || Operations.isTotal(automata.get(automata.size() - 1)) == 
false) {

Review Comment:
   Good call — done, using `automata.getLast()` now (the `isEmpty()` check 
keeps it safe). Pushed.



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

Reply via email to