Search in sources :

Example 1 with LargeNumHitsCollector

use of com.yelp.nrtsearch.server.luceneserver.search.collectors.LargeNumHitsCollector in project nrtsearch by Yelp.

the class SearchRequestProcessor method buildDocCollector.

/**
 * Build {@link DocCollector} to provide the {@link org.apache.lucene.search.CollectorManager} for
 * collecting hits for this query.
 *
 * @return collector
 */
private static DocCollector buildDocCollector(CollectorCreatorContext collectorCreatorContext) {
    SearchRequest searchRequest = collectorCreatorContext.getRequest();
    List<AdditionalCollectorManager<? extends Collector, ? extends CollectorResult>> additionalCollectors = searchRequest.getCollectorsMap().entrySet().stream().map(e -> CollectorCreator.getInstance().createCollectorManager(collectorCreatorContext, e.getKey(), e.getValue())).collect(Collectors.toList());
    if (searchRequest.getQuerySort().getFields().getSortedFieldsList().isEmpty()) {
        if (hasLargeNumHits(searchRequest)) {
            return new LargeNumHitsCollector(collectorCreatorContext, additionalCollectors);
        } else {
            return new RelevanceCollector(collectorCreatorContext, additionalCollectors);
        }
    } else {
        return new SortFieldCollector(collectorCreatorContext, additionalCollectors);
    }
}
Also used : SearchResponse(com.yelp.nrtsearch.server.grpc.SearchResponse) ScriptParamsUtils(com.yelp.nrtsearch.server.utils.ScriptParamsUtils) SearcherTaxonomyManager(org.apache.lucene.facet.taxonomy.SearcherTaxonomyManager) Query(org.apache.lucene.search.Query) QueryRescorer(com.yelp.nrtsearch.server.grpc.QueryRescorer) PluginRescorer(com.yelp.nrtsearch.server.grpc.PluginRescorer) HashMap(java.util.HashMap) AdditionalCollectorManager(com.yelp.nrtsearch.server.luceneserver.search.collectors.AdditionalCollectorManager) VirtualField(com.yelp.nrtsearch.server.grpc.VirtualField) CollectorCreator(com.yelp.nrtsearch.server.luceneserver.search.collectors.CollectorCreator) ArrayList(java.util.ArrayList) QueryBuilder(org.apache.lucene.util.QueryBuilder) MultiFieldQueryParser(org.apache.lucene.queryparser.classic.MultiFieldQueryParser) VirtualFieldDef(com.yelp.nrtsearch.server.luceneserver.field.VirtualFieldDef) IndexableFieldDef(com.yelp.nrtsearch.server.luceneserver.field.IndexableFieldDef) Map(java.util.Map) DrillDownQuery(org.apache.lucene.facet.DrillDownQuery) ShardState(com.yelp.nrtsearch.server.luceneserver.ShardState) ScoreScript(com.yelp.nrtsearch.server.luceneserver.script.ScoreScript) DefaultSharedDocContext(com.yelp.nrtsearch.server.luceneserver.doc.DefaultSharedDocContext) SimpleQueryParser(org.apache.lucene.queryparser.simple.SimpleQueryParser) QueryParserBase(org.apache.lucene.queryparser.classic.QueryParserBase) CollectorResult(com.yelp.nrtsearch.server.grpc.CollectorResult) FieldDef(com.yelp.nrtsearch.server.luceneserver.field.FieldDef) CollectorCreatorContext(com.yelp.nrtsearch.server.luceneserver.search.collectors.CollectorCreatorContext) RescoreTask(com.yelp.nrtsearch.server.luceneserver.rescore.RescoreTask) QueryNodeMapper(com.yelp.nrtsearch.server.luceneserver.QueryNodeMapper) QueryRescore(com.yelp.nrtsearch.server.luceneserver.rescore.QueryRescore) RescoreOperation(com.yelp.nrtsearch.server.luceneserver.rescore.RescoreOperation) DocCollector(com.yelp.nrtsearch.server.luceneserver.search.collectors.DocCollector) IOException(java.io.IOException) IndexState(com.yelp.nrtsearch.server.luceneserver.IndexState) Collector(org.apache.lucene.search.Collector) ProfileResult(com.yelp.nrtsearch.server.grpc.ProfileResult) Collectors(java.util.stream.Collectors) LargeNumHitsCollector(com.yelp.nrtsearch.server.luceneserver.search.collectors.LargeNumHitsCollector) ScriptService(com.yelp.nrtsearch.server.luceneserver.script.ScriptService) SearchRequest(com.yelp.nrtsearch.server.grpc.SearchRequest) List(java.util.List) RescorerCreator(com.yelp.nrtsearch.server.luceneserver.rescore.RescorerCreator) SortFieldCollector(com.yelp.nrtsearch.server.luceneserver.search.collectors.SortFieldCollector) RelevanceCollector(com.yelp.nrtsearch.server.luceneserver.search.collectors.RelevanceCollector) Collections(java.util.Collections) IndexSearcher(org.apache.lucene.search.IndexSearcher) SearchRequest(com.yelp.nrtsearch.server.grpc.SearchRequest) CollectorResult(com.yelp.nrtsearch.server.grpc.CollectorResult) AdditionalCollectorManager(com.yelp.nrtsearch.server.luceneserver.search.collectors.AdditionalCollectorManager) LargeNumHitsCollector(com.yelp.nrtsearch.server.luceneserver.search.collectors.LargeNumHitsCollector) DocCollector(com.yelp.nrtsearch.server.luceneserver.search.collectors.DocCollector) Collector(org.apache.lucene.search.Collector) LargeNumHitsCollector(com.yelp.nrtsearch.server.luceneserver.search.collectors.LargeNumHitsCollector) SortFieldCollector(com.yelp.nrtsearch.server.luceneserver.search.collectors.SortFieldCollector) RelevanceCollector(com.yelp.nrtsearch.server.luceneserver.search.collectors.RelevanceCollector) RelevanceCollector(com.yelp.nrtsearch.server.luceneserver.search.collectors.RelevanceCollector) SortFieldCollector(com.yelp.nrtsearch.server.luceneserver.search.collectors.SortFieldCollector)

Aggregations

CollectorResult (com.yelp.nrtsearch.server.grpc.CollectorResult)1 PluginRescorer (com.yelp.nrtsearch.server.grpc.PluginRescorer)1 ProfileResult (com.yelp.nrtsearch.server.grpc.ProfileResult)1 QueryRescorer (com.yelp.nrtsearch.server.grpc.QueryRescorer)1 SearchRequest (com.yelp.nrtsearch.server.grpc.SearchRequest)1 SearchResponse (com.yelp.nrtsearch.server.grpc.SearchResponse)1 VirtualField (com.yelp.nrtsearch.server.grpc.VirtualField)1 IndexState (com.yelp.nrtsearch.server.luceneserver.IndexState)1 QueryNodeMapper (com.yelp.nrtsearch.server.luceneserver.QueryNodeMapper)1 ShardState (com.yelp.nrtsearch.server.luceneserver.ShardState)1 DefaultSharedDocContext (com.yelp.nrtsearch.server.luceneserver.doc.DefaultSharedDocContext)1 FieldDef (com.yelp.nrtsearch.server.luceneserver.field.FieldDef)1 IndexableFieldDef (com.yelp.nrtsearch.server.luceneserver.field.IndexableFieldDef)1 VirtualFieldDef (com.yelp.nrtsearch.server.luceneserver.field.VirtualFieldDef)1 QueryRescore (com.yelp.nrtsearch.server.luceneserver.rescore.QueryRescore)1 RescoreOperation (com.yelp.nrtsearch.server.luceneserver.rescore.RescoreOperation)1 RescoreTask (com.yelp.nrtsearch.server.luceneserver.rescore.RescoreTask)1 RescorerCreator (com.yelp.nrtsearch.server.luceneserver.rescore.RescorerCreator)1 ScoreScript (com.yelp.nrtsearch.server.luceneserver.script.ScoreScript)1 ScriptService (com.yelp.nrtsearch.server.luceneserver.script.ScriptService)1