Java Code Examples for org.apache.lucene.search.MultiCollector#wrap()
The following examples show how to use
org.apache.lucene.search.MultiCollector#wrap() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Grouping.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override protected Collector createFirstPassCollector() throws IOException { DocSet groupFilt = searcher.getDocSet(query); int groupDocsToCollect = getMax(groupOffset, docsPerGroup, maxDoc); Collector subCollector; if (withinGroupSort == null || withinGroupSort.equals(Sort.RELEVANCE)) { subCollector = topCollector = TopScoreDocCollector.create(groupDocsToCollect, Integer.MAX_VALUE); } else { topCollector = TopFieldCollector.create(searcher.weightSort(withinGroupSort), groupDocsToCollect, Integer.MAX_VALUE); if (needScores) { maxScoreCollector = new MaxScoreCollector(); subCollector = MultiCollector.wrap(topCollector, maxScoreCollector); } else { subCollector = topCollector; } } collector = new FilterCollector(groupFilt, subCollector); return collector; }
Example 2
Source File: QueryCommand.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public List<Collector> create() throws IOException { Collector subCollector; if (sort == null || sort.equals(Sort.RELEVANCE)) { subCollector = topDocsCollector = TopScoreDocCollector.create(docsToCollect, Integer.MAX_VALUE); } else { topDocsCollector = TopFieldCollector.create(sort, docsToCollect, Integer.MAX_VALUE); if (needScores) { maxScoreCollector = new MaxScoreCollector(); subCollector = MultiCollector.wrap(topDocsCollector, maxScoreCollector); } else { subCollector = topDocsCollector; } } filterCollector = new FilterCollector(docSet, subCollector); return Arrays.asList((Collector) filterCollector); }
Example 3
Source File: CommandHandler.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Invokes search with the specified filter and collector. * If a time limit has been specified then wrap the collector in the TimeLimitingCollector */ private void searchWithTimeLimiter(Query query, ProcessedFilter filter, Collector collector) throws IOException { if (queryCommand.getTimeAllowed() > 0 ) { collector = new TimeLimitingCollector(collector, TimeLimitingCollector.getGlobalCounter(), queryCommand.getTimeAllowed()); } TotalHitCountCollector hitCountCollector = new TotalHitCountCollector(); if (includeHitCount) { collector = MultiCollector.wrap(collector, hitCountCollector); } query = QueryUtils.combineQueryAndFilter(query, filter.filter); if (filter.postFilter != null) { filter.postFilter.setLastDelegate(collector); collector = filter.postFilter; } try { searcher.search(query, collector); } catch (TimeLimitingCollector.TimeExceededException | ExitableDirectoryReader.ExitingReaderException x) { partialResults = true; log.warn("Query: {}; {}", query, x.getMessage()); } if (includeHitCount) { totalHitCount = hitCountCollector.getTotalHits(); } }
Example 4
Source File: LindenDocsCollector.java From linden with Apache License 2.0 | 4 votes |
public void wrap(Collector collector) { wrappedCollector = MultiCollector.wrap(collector, wrappedCollector); }
Example 5
Source File: GroupingSearch.java From lucene-solr with Apache License 2.0 | 4 votes |
@SuppressWarnings({"unchecked", "rawtypes"}) protected TopGroups groupByFieldOrFunction(IndexSearcher searcher, Query query, int groupOffset, int groupLimit) throws IOException { int topN = groupOffset + groupLimit; final FirstPassGroupingCollector firstPassCollector = new FirstPassGroupingCollector(grouper, groupSort, topN); final AllGroupsCollector allGroupsCollector = allGroups ? new AllGroupsCollector(grouper) : null; final AllGroupHeadsCollector allGroupHeadsCollector = allGroupHeads ? AllGroupHeadsCollector.newCollector(grouper, sortWithinGroup) : null; final Collector firstRound = MultiCollector.wrap(firstPassCollector, allGroupsCollector, allGroupHeadsCollector); CachingCollector cachedCollector = null; if (maxCacheRAMMB != null || maxDocsToCache != null) { if (maxCacheRAMMB != null) { cachedCollector = CachingCollector.create(firstRound, cacheScores, maxCacheRAMMB); } else { cachedCollector = CachingCollector.create(firstRound, cacheScores, maxDocsToCache); } searcher.search(query, cachedCollector); } else { searcher.search(query, firstRound); } matchingGroups = allGroups ? allGroupsCollector.getGroups() : Collections.emptyList(); matchingGroupHeads = allGroupHeads ? allGroupHeadsCollector.retrieveGroupHeads(searcher.getIndexReader().maxDoc()) : new Bits.MatchNoBits(searcher.getIndexReader().maxDoc()); Collection<SearchGroup> topSearchGroups = firstPassCollector.getTopGroups(groupOffset); if (topSearchGroups == null) { return new TopGroups(new SortField[0], new SortField[0], 0, 0, new GroupDocs[0], Float.NaN); } int topNInsideGroup = groupDocsOffset + groupDocsLimit; TopGroupsCollector secondPassCollector = new TopGroupsCollector(grouper, topSearchGroups, groupSort, sortWithinGroup, topNInsideGroup, includeMaxScore); if (cachedCollector != null && cachedCollector.isCached()) { cachedCollector.replay(secondPassCollector); } else { searcher.search(query, secondPassCollector); } if (allGroups) { return new TopGroups(secondPassCollector.getTopGroups(groupDocsOffset), matchingGroups.size()); } else { return secondPassCollector.getTopGroups(groupDocsOffset); } }
Example 6
Source File: TopGroupsCollector.java From lucene-solr with Apache License 2.0 | 4 votes |
public TopDocsAndMaxScoreCollector(boolean sortedByScore, TopDocsCollector<?> topDocsCollector, MaxScoreCollector maxScoreCollector) { super(MultiCollector.wrap(topDocsCollector, maxScoreCollector)); this.sortedByScore = sortedByScore; this.topDocsCollector = topDocsCollector; this.maxScoreCollector = maxScoreCollector; }