public UnionDocsAndPositionsEnum(IBits liveDocs, AtomicReaderContext context, Term[] terms, IDictionary <Term, TermContext> termContexts, TermsEnum termsEnum) { ICollection <DocsAndPositionsEnum> docsEnums = new LinkedList <DocsAndPositionsEnum>(); for (int i = 0; i < terms.Length; i++) { Term term = terms[i]; TermState termState = termContexts[term].Get(context.Ord); if (termState == null) { // Term doesn't exist in reader continue; } termsEnum.SeekExact(term.Bytes, termState); DocsAndPositionsEnum postings = termsEnum.DocsAndPositions(liveDocs, null, DocsAndPositionsFlags.NONE); if (postings == null) { // term does exist, but has no positions throw new InvalidOperationException("field \"" + term.Field + "\" was indexed without position data; cannot run PhraseQuery (term=" + term.Text() + ")"); } _cost += postings.GetCost(); docsEnums.Add(postings); } _queue = new DocsQueue(docsEnums); _posList = new Int32Queue(); }