madrob commented on a change in pull request #1042: LUCENE-9068: Build 
FuzzyQuery automata up-front
URL: https://github.com/apache/lucene-solr/pull/1042#discussion_r362860923
 
 

 ##########
 File path: lucene/core/src/java/org/apache/lucene/search/FuzzyQuery.java
 ##########
 @@ -150,26 +167,13 @@ public boolean getTranspositions() {
     return transpositions;
   }
 
-  /**
-   * Expert: Constructs an equivalent Automaton accepting terms matched by 
this query
-   */
-  public Automaton toAutomaton() {
-    return FuzzyTermsEnum.buildAutomaton(term.text(), prefixLength, 
transpositions, maxEdits);
-  }
-
   @Override
   public void visit(QueryVisitor visitor) {
     if (visitor.acceptField(field)) {
       if (maxEdits == 0 || prefixLength >= term.text().length()) {
         visitor.consumeTerms(this, term);
       } else {
-        // Note: we're rebuilding the automaton here, so this can be expensive
-        try {
-          visitor.consumeTermsMatching(this, field,
-              new ByteRunAutomaton(toAutomaton(), false, 
Operations.DEFAULT_MAX_DETERMINIZED_STATES));
-        } catch (TooComplexToDeterminizeException e) {
-          throw new FuzzyTermsEnum.FuzzyTermsException(term.text(), e);
-        }
+        automata[automata.length - 1].visit(visitor, this, field);
 
 Review comment:
   👍 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to