Java Code Examples for org.apache.lucene.util.Bits#MatchNoBits
The following examples show how to use
org.apache.lucene.util.Bits#MatchNoBits .
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: MissingAggregator.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { final Bits docsWithValue; if (valuesSource != null) { docsWithValue = valuesSource.docsWithValue(ctx); } else { docsWithValue = new Bits.MatchNoBits(ctx.reader().maxDoc()); } return new LeafBucketCollectorBase(sub, docsWithValue) { @Override public void collect(int doc, long bucket) throws IOException { if (docsWithValue != null && !docsWithValue.get(doc)) { collectBucket(sub, doc, bucket); } } }; }
Example 2
Source File: FieldCacheImpl.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public Bits getDocsWithField(LeafReader reader, String field, Parser parser) throws IOException { final FieldInfo fieldInfo = reader.getFieldInfos().fieldInfo(field); if (fieldInfo == null) { // field does not exist or has no value return new Bits.MatchNoBits(reader.maxDoc()); } if (fieldInfo.getDocValuesType() != DocValuesType.NONE) { // doc values case } else if (parser instanceof PointParser) { // points case } else { // postings case if (fieldInfo.getIndexOptions() == IndexOptions.NONE) { return new Bits.MatchNoBits(reader.maxDoc()); } } BitsEntry bitsEntry = (BitsEntry) caches.get(DocsWithFieldCache.class).get(reader, new CacheKey(field, parser)); return bitsEntry.bits; }
Example 3
Source File: CompletionWeight.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public BulkScorer bulkScorer(final LeafReaderContext context) throws IOException { final LeafReader reader = context.reader(); final Terms terms; final NRTSuggester suggester; if ((terms = reader.terms(completionQuery.getField())) == null) { return null; } if (terms instanceof CompletionTerms) { CompletionTerms completionTerms = (CompletionTerms) terms; if ((suggester = completionTerms.suggester()) == null) { // a segment can have a null suggester // i.e. no FST was built return null; } } else { throw new IllegalArgumentException(completionQuery.getField() + " is not a SuggestField"); } BitsProducer filter = completionQuery.getFilter(); Bits filteredDocs = null; if (filter != null) { filteredDocs = filter.getBits(context); if (filteredDocs.getClass() == Bits.MatchNoBits.class) { return null; } } return new CompletionScorer(this, suggester, reader, filteredDocs, filter != null, automaton); }
Example 4
Source File: FieldCacheImpl.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public long ramBytesUsed() { long base = RamUsageEstimator.NUM_BYTES_OBJECT_REF; if (bits instanceof Bits.MatchAllBits || bits instanceof Bits.MatchNoBits) { return base; } else { return base + (bits.length() >>> 3); } }
Example 5
Source File: FacetHeatmap.java From lucene-solr with Apache License 2.0 | 5 votes |
private Bits getTopAcceptDocs(DocSet docSet, SolrIndexSearcher searcher) throws IOException { if (docSet.size() == searcher.numDocs()) { return null; // means match everything (all live docs). This can speedup things a lot. } else if (docSet.size() == 0) { return new Bits.MatchNoBits(searcher.maxDoc()); // can speedup things a lot } else { return docSet.getBits(); } }
Example 6
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); } }