dsmiley commented on a change in pull request #1037: LUCENE-9062: QueryVisitor.consumeTermsMatching URL: https://github.com/apache/lucene-solr/pull/1037#discussion_r350484695
########## File path: lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/MultiTermHighlighting.java ########## @@ -86,85 +87,10 @@ public QueryVisitor getSubVisitor(BooleanClause.Occur occur, Query parent) { } @Override - public void visitLeaf(Query query) { - if (query instanceof AutomatonQuery) { - AutomatonQuery aq = (AutomatonQuery) query; - if (aq.isAutomatonBinary() == false) { - // WildcardQuery, RegexpQuery - runAutomata.add(new CharacterRunAutomaton(aq.getAutomaton()) { - @Override - public String toString() { - return query.toString(); - } - }); - } - else { - runAutomata.add(binaryToCharRunAutomaton(aq.getAutomaton(), query.toString())); - } - } - else if (query instanceof FuzzyQuery) { - FuzzyQuery fq = (FuzzyQuery) query; - if (fq.getMaxEdits() == 0 || fq.getPrefixLength() >= fq.getTerm().text().length()) { - consumeTerms(query, fq.getTerm()); - } - else { - runAutomata.add(new CharacterRunAutomaton(fq.toAutomaton()){ - @Override - public String toString() { - return query.toString(); - } - }); - } - } + public void consumeTermsMatching(Query query, String field, ByteRunAutomaton automaton) { + runAutomata.add(automaton.asCharArrayMatcher(query.toString())); } } - private static CharacterRunAutomaton binaryToCharRunAutomaton(Automaton binaryAutomaton, String description) { - return new CharacterRunAutomaton(Automata.makeEmpty()) { // empty here is bogus just to satisfy API - // TODO can we get access to the aq.compiledAutomaton.runAutomaton ? Review comment: From what I see, and I'm not certain, you've succeeded in re-using the underlying AutomatonQuery's CompiledAutomaton.runAutomaton :-) ---------------------------------------------------------------- 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