Java Code Examples for org.apache.solr.search.DocIterator#nextDoc()
The following examples show how to use
org.apache.solr.search.DocIterator#nextDoc() .
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: BlockJoin.java From lucene-solr with Apache License 2.0 | 6 votes |
/** acceptDocs will normally be used to avoid deleted documents from being generated as part of the answer DocSet (just use *:*) * although it can be used to further constrain the generated documents. */ public static DocSet toChildren(DocSet parentInput, BitDocSet parentList, DocSet acceptDocs, QueryContext qcontext) throws IOException { FixedBitSet parentBits = parentList.getBits(); DocSetCollector collector = new DocSetCollector(qcontext.searcher().maxDoc()); DocIterator iter = parentInput.iterator(); while (iter.hasNext()) { int parentDoc = iter.nextDoc(); if (!parentList.exists(parentDoc) || parentDoc == 0) { // test for parentDoc==0 here to avoid passing -1 to prevSetBit later on // not a parent, or parent has no children continue; } int prevParent = parentBits.prevSetBit(parentDoc - 1); for (int childDoc = prevParent+1; childDoc<parentDoc; childDoc++) { if (acceptDocs != null && !acceptDocs.exists(childDoc)) continue; // only select live docs collector.collect(childDoc); } } return collector.getDocSet(); }
Example 2
Source File: BlockJoin.java From lucene-solr with Apache License 2.0 | 6 votes |
/** childInput may also contain parents (i.e. a parent or below will all roll up to that parent) */ public static DocSet toParents(DocSet childInput, BitDocSet parentList, QueryContext qcontext) throws IOException { FixedBitSet parentBits = parentList.getBits(); DocSetCollector collector = new DocSetCollector(qcontext.searcher().maxDoc()); DocIterator iter = childInput.iterator(); int currentParent = -1; while (iter.hasNext()) { int childDoc = iter.nextDoc(); // TODO: skipping if (childDoc <= currentParent) { // use <= since we also allow parents in the input // we already visited this parent continue; } currentParent = parentBits.nextSetBit(childDoc); if (currentParent != DocIdSetIterator.NO_MORE_DOCS) { // only collect the parent the first time we skip to it collector.collect( currentParent ); } } return collector.getDocSet(); }
Example 3
Source File: SolrPluginUtils.java From lucene-solr with Apache License 2.0 | 6 votes |
/** * Generates an NamedList of Explanations for each item in a list of docs. * * @param query The Query you want explanations in the context of * @param docs The Documents you want explained relative that query */ public static NamedList<Explanation> getExplanations (Query query, DocList docs, SolrIndexSearcher searcher, IndexSchema schema) throws IOException { NamedList<Explanation> explainList = new SimpleOrderedMap<>(); DocIterator iterator = docs.iterator(); for (int i=0; i<docs.size(); i++) { int id = iterator.nextDoc(); Document doc = searcher.doc(id); String strid = schema.printableUniqueKey(doc); explainList.add(strid, searcher.explain(query, id) ); } return explainList; }
Example 4
Source File: UnifiedSolrHighlighter.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Converts solr's DocList to the int[] docIDs */ protected int[] toDocIDs(DocList docs) { int[] docIDs = new int[docs.size()]; DocIterator iterator = docs.iterator(); for (int i = 0; i < docIDs.length; i++) { if (!iterator.hasNext()) { throw new AssertionError(); } docIDs[i] = iterator.nextDoc(); } if (iterator.hasNext()) { throw new AssertionError(); } return docIDs; }