bruno-roustant commented on a change in pull request #780: SOLR-11866: Support efficient subset matching in query elevation rules URL: https://github.com/apache/lucene-solr/pull/780#discussion_r303909793
########## File path: solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java ########## @@ -701,28 +703,20 @@ protected ElevationProvider createElevationProvider(Map<ElevatingQuery, Elevatio * Analyzes the provided query string and returns a concatenation of the analyzed tokens. */ public String analyzeQuery(String query) { - StringBuilder concatenatedTerms = new StringBuilder(); - analyzeQuery(query, null, concatenatedTerms); - return concatenatedTerms.toString(); + StringBuilder concatTerms = new StringBuilder(); + analyzeQuery(query, concatTerms::append); + return concatTerms.toString(); } /** - * Analyzes the provided query string, tokenizes the terms and add them to either the provided {@link Collection} or {@link Appendable}. - * - * @param queryTerms The {@link Collection} that receives the terms; or null if none. - * @param concatenatedTerms The {@link Appendable} that receives the terms; or null if none. + * Analyzes the provided query string, tokenizes the terms, and adds them to the provided {@link Consumer}. */ - protected void analyzeQuery(String query, Collection<String> queryTerms, Appendable concatenatedTerms) { + protected void analyzeQuery(String query, Consumer<String> termsConsumer) { try (TokenStream tokens = queryAnalyzer.tokenStream("", query)) { tokens.reset(); CharTermAttribute termAtt = tokens.addAttribute(CharTermAttribute.class); while (tokens.incrementToken()) { - if (queryTerms != null) { - queryTerms.add(termAtt.toString()); - } - if (concatenatedTerms != null) { - concatenatedTerms.append(termAtt); - } + termsConsumer.accept(termAtt.toString()); Review comment: I'll change to a Consumer<CharSequence>. ---------------------------------------------------------------- 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: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org