org.apache.lucene.search.BitsFilteredDocIdSet Java Examples
The following examples show how to use
org.apache.lucene.search.BitsFilteredDocIdSet.
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: ParentQuery.java From Elasticsearch with Apache License 2.0 | 7 votes |
@Override public Scorer scorer(LeafReaderContext context) throws IOException { DocIdSet childrenDocSet = childrenFilter.getDocIdSet(context, null); // we forcefully apply live docs here so that deleted children don't give matching parents childrenDocSet = BitsFilteredDocIdSet.wrap(childrenDocSet, context.reader().getLiveDocs()); if (Lucene.isEmpty(childrenDocSet)) { return null; } final DocIdSetIterator childIterator = childrenDocSet.iterator(); if (childIterator == null) { return null; } SortedDocValues bytesValues = globalIfd.load(context).getOrdinalsValues(parentType); if (bytesValues == null) { return null; } return new ChildScorer(this, parentIdxs, scores, childIterator, bytesValues); }
Example #2
Source File: ParentConstantScoreQuery.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public Scorer scorer(LeafReaderContext context) throws IOException { DocIdSet childrenDocIdSet = childrenFilter.getDocIdSet(context, null); if (Lucene.isEmpty(childrenDocIdSet)) { return null; } SortedDocValues globalValues = globalIfd.load(context).getOrdinalsValues(parentType); if (globalValues != null) { // we forcefully apply live docs here so that deleted children don't give matching parents childrenDocIdSet = BitsFilteredDocIdSet.wrap(childrenDocIdSet, context.reader().getLiveDocs()); DocIdSetIterator innerIterator = childrenDocIdSet.iterator(); if (innerIterator != null) { ChildrenDocIdIterator childrenDocIdIterator = new ChildrenDocIdIterator( innerIterator, parentOrds, globalValues ); return ConstantScorer.create(childrenDocIdIterator, this, queryWeight); } } return null; }
Example #3
Source File: ChildrenQuery.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public Scorer scorer(LeafReaderContext context) throws IOException { DocIdSet parentsSet = parentFilter.getDocIdSet(context, null); if (Lucene.isEmpty(parentsSet) || remaining == 0) { return null; } // We can't be sure of the fact that liveDocs have been applied, so we apply it here. The "remaining" // count down (short circuit) logic will then work as expected. DocIdSetIterator parents = BitsFilteredDocIdSet.wrap(parentsSet, context.reader().getLiveDocs()).iterator(); if (parents != null) { SortedDocValues bytesValues = collector.globalIfd.load(context).getOrdinalsValues(parentType); if (bytesValues == null) { return null; } if (minChildren > 0 || maxChildren != 0 || scoreType == ScoreType.NONE) { switch (scoreType) { case NONE: DocIdSetIterator parentIdIterator = new CountParentOrdIterator(this, parents, collector, bytesValues, minChildren, maxChildren); return ConstantScorer.create(parentIdIterator, this, queryWeight); case AVG: return new AvgParentCountScorer(this, parents, collector, bytesValues, minChildren, maxChildren); default: return new ParentCountScorer(this, parents, collector, bytesValues, minChildren, maxChildren); } } switch (scoreType) { case AVG: return new AvgParentScorer(this, parents, collector, bytesValues); default: return new ParentScorer(this, parents, collector, bytesValues); } } return null; }
Example #4
Source File: ChildrenConstantScoreQuery.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public Scorer scorer(LeafReaderContext context) throws IOException { if (remaining == 0) { return null; } if (shortCircuitFilter != null) { DocIdSet docIdSet = shortCircuitFilter.getDocIdSet(context, null); if (!Lucene.isEmpty(docIdSet)) { DocIdSetIterator iterator = docIdSet.iterator(); if (iterator != null) { return ConstantScorer.create(iterator, this, queryWeight); } } return null; } DocIdSet parentDocIdSet = this.parentFilter.getDocIdSet(context, null); if (!Lucene.isEmpty(parentDocIdSet)) { // We can't be sure of the fact that liveDocs have been applied, so we apply it here. The "remaining" // count down (short circuit) logic will then work as expected. parentDocIdSet = BitsFilteredDocIdSet.wrap(parentDocIdSet, context.reader().getLiveDocs()); DocIdSetIterator innerIterator = parentDocIdSet.iterator(); if (innerIterator != null) { LongBitSet parentOrds = collector.parentOrds; SortedDocValues globalValues = globalIfd.load(context).getOrdinalsValues(parentType); if (globalValues != null) { DocIdSetIterator parentIdIterator = new ParentOrdIterator(innerIterator, parentOrds, globalValues, this); return ConstantScorer.create(parentIdIterator, this, queryWeight); } } } return null; }
Example #5
Source File: FilterCache.java From incubator-retired-blur with Apache License 2.0 | 5 votes |
@Override public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws IOException { AtomicReader reader = context.reader(); Object key = reader.getCoreCacheKey(); DocIdSet docIdSet = _cache.get(key); if (docIdSet != null) { _hits.incrementAndGet(); return BitsFilteredDocIdSet.wrap(docIdSet, acceptDocs); } // This will only allow a single instance be created per reader per filter Object lock = getLock(key); synchronized (lock) { SegmentReader segmentReader = getSegmentReader(reader); if (segmentReader == null) { LOG.warn("Could not find SegmentReader from [{0}]", reader); return _filter.getDocIdSet(context, acceptDocs); } Directory directory = getDirectory(segmentReader); if (directory == null) { LOG.warn("Could not find Directory from [{0}]", segmentReader); return _filter.getDocIdSet(context, acceptDocs); } _misses.incrementAndGet(); String segmentName = segmentReader.getSegmentName(); docIdSet = docIdSetToCache(_filter.getDocIdSet(context, null), reader, segmentName, directory); _cache.put(key, docIdSet); return BitsFilteredDocIdSet.wrap(docIdSet, acceptDocs); } }
Example #6
Source File: NotNullFieldFilter.java From linden with Apache License 2.0 | 4 votes |
@Override public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws IOException { DocIdSet docIdSet = LindenFieldCacheImpl.DEFAULT.getNotNullFieldDocIdSet(context.reader(), fieldName); return BitsFilteredDocIdSet.wrap(docIdSet, acceptDocs); }