List of usage examples for org.apache.lucene.search ConjunctionDISI intersectIterators
public static DocIdSetIterator intersectIterators(List<DocIdSetIterator> iterators)
From source file:org.elasticsearch.xpack.core.security.authz.accesscontrol.SecurityIndexSearcherWrapper.java
License:Open Source License
static void intersectScorerAndRoleBits(Scorer scorer, SparseFixedBitSet roleBits, LeafCollector collector, Bits acceptDocs) throws IOException { // ConjunctionDISI uses the DocIdSetIterator#cost() to order the iterators, so if roleBits has the lowest cardinality it should // be used first: DocIdSetIterator iterator = ConjunctionDISI.intersectIterators( Arrays.asList(new BitSetIterator(roleBits, roleBits.approximateCardinality()), scorer.iterator())); for (int docId = iterator.nextDoc(); docId < DocIdSetIterator.NO_MORE_DOCS; docId = iterator.nextDoc()) { if (acceptDocs == null || acceptDocs.get(docId)) { collector.collect(docId);//w ww . ja v a 2 s .c om } } }
From source file:org.opengrok.suggest.query.customized.CustomExactPhraseScorer.java
License:Apache License
/** * Creates custom exact phrase scorer which remembers the positions of the found matches. * @param weight query weight/*from w w w.ja v a 2 s. c om*/ * @param postings postings of the terms * @param offset the offset that is added to the found match position */ CustomExactPhraseScorer(final Weight weight, final CustomPhraseQuery.PostingsAndFreq[] postings, final int offset) { super(weight); this.offset = offset; // custom List<DocIdSetIterator> iterators = new ArrayList<>(); List<PostingsAndPosition> postingsAndPositions = new ArrayList<>(); for (CustomPhraseQuery.PostingsAndFreq posting : postings) { iterators.add(posting.postings); postingsAndPositions.add(new PostingsAndPosition(posting.postings, posting.position)); } // custom begins support for single term if (iterators.size() == 1) { conjunction = iterators.get(0); } else { conjunction = ConjunctionDISI.intersectIterators(iterators); } // custom ends assert TwoPhaseIterator.unwrap(conjunction) == null; this.postings = postingsAndPositions.toArray(new PostingsAndPosition[postingsAndPositions.size()]); }
From source file:org.opengrok.suggest.query.customized.CustomSloppyPhraseScorer.java
License:Apache License
/** * Creates custom sloppy phrase scorer which remembers the positions of the found matches. * @param weight query weight/* ww w.j a v a 2 s.c o m*/ * @param postings postings of the terms * @param slop "word edit distance" * @param offset the offset that is added to the found match position */ CustomSloppyPhraseScorer(final Weight weight, final CustomPhraseQuery.PostingsAndFreq[] postings, final int slop, final int offset) { super(weight); this.slop = slop; this.offset = offset; // custom this.numPostings = postings == null ? 0 : postings.length; pq = new PhraseQueue(postings.length); DocIdSetIterator[] iterators = new DocIdSetIterator[postings.length]; phrasePositions = new PhrasePositions[postings.length]; for (int i = 0; i < postings.length; ++i) { iterators[i] = postings[i].postings; phrasePositions[i] = new PhrasePositions(postings[i].postings, postings[i].position, i, postings[i].terms); } // custom begins support for single term if (iterators.length == 1) { conjunction = iterators[0]; } else { conjunction = ConjunctionDISI.intersectIterators(Arrays.asList(iterators)); } // custom ends assert TwoPhaseIterator.unwrap(conjunction) == null; }