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_r303824411
########## File path: solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java ########## @@ -682,35 +686,48 @@ public String getDescription() { * Creates the {@link ElevationProvider} to set during configuration loading. The same instance will be used later * when elevating results for queries. * - * @param queryAnalyzer to analyze and tokenize the query. * @param elevationBuilderMap map of all {@link ElevatingQuery} and their corresponding {@link ElevationBuilder}. * @return The created {@link ElevationProvider}. */ - protected ElevationProvider createElevationProvider(Analyzer queryAnalyzer, Map<ElevatingQuery, ElevationBuilder> elevationBuilderMap) { - return new MapElevationProvider(elevationBuilderMap); + protected ElevationProvider createElevationProvider(Map<ElevatingQuery, ElevationBuilder> elevationBuilderMap) { + return new SubsetMatchElevationProvider(new TrieSubsetMatcher.Builder<>(), elevationBuilderMap); } //--------------------------------------------------------------------------------- // Query analysis and tokenization //--------------------------------------------------------------------------------- /** - * Analyzes the provided query string and returns a space concatenation of the analyzed tokens. + * Analyzes the provided query string and returns a concatenation of the analyzed tokens. */ public String analyzeQuery(String query) { - //split query terms with analyzer then join - StringBuilder norm = new StringBuilder(); + StringBuilder concatenatedTerms = new StringBuilder(); + analyzeQuery(query, null, concatenatedTerms); + return concatenatedTerms.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. + */ + protected void analyzeQuery(String query, Collection<String> queryTerms, Appendable concatenatedTerms) { Review comment: I pondered for a while on this signature, because I wanted it to be clear but also performant where it is used, to avoid the creation of lots of lambdas in loops. I'll change back to the Consumer. It will create just an additional lambda instance per query to process, given that I'll declare the lambdas out of the loops. ---------------------------------------------------------------- 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