20 using Lucene.Net.Index;
21 using Document = Lucene.Net.Documents.Document;
29 namespace Lucene.Net.Search
50 private bool closeReader;
51 private bool isDisposed;
56 private int[] docStarts;
106 this.reader = reader;
107 this.subReaders = subReaders;
108 this.docStarts = docStarts;
109 this.closeReader =
false;
115 this.closeReader = closeReader;
117 System.Collections.Generic.IList<
IndexReader> subReadersList =
new System.Collections.Generic.List<
IndexReader>();
118 GatherSubReaders(subReadersList, reader);
119 subReaders = subReadersList.ToArray();
120 docStarts =
new int[subReaders.Length];
122 for (
int i = 0; i < subReaders.Length; i++)
124 docStarts[i] = maxDoc;
125 maxDoc += subReaders[i].
MaxDoc;
129 protected internal virtual void GatherSubReaders(System.Collections.Generic.IList<
IndexReader> allSubReaders,
IndexReader r)
131 ReaderUtil.GatherSubReaders(allSubReaders, r);
137 get {
return reader; }
140 protected override void Dispose(
bool disposing)
142 if (isDisposed)
return;
154 public override int DocFreq(
Term term)
156 return reader.DocFreq(term);
162 return reader.Document(i);
168 return reader.Document(i, fieldSelector);
172 public override int MaxDoc
174 get {
return reader.MaxDoc; }
183 throw new System.ArgumentException(
"nDocs must be > 0");
185 nDocs = Math.Min(nDocs, reader.MaxDoc);
188 Search(weight, filter, collector);
194 return Search(weight, filter, nDocs, sort,
true);
209 nDocs = Math.Min(nDocs, reader.MaxDoc);
212 Search(weight, filter, collector2);
221 for (
int i = 0; i < subReaders.Length; i++)
228 scorer.
Score(collector);
234 for (
int i = 0; i < subReaders.Length; i++)
238 SearchWithFilter(subReaders[i], weight, filter, collector);
246 System.Diagnostics.Debug.Assert(filter != null);
254 int docID = scorer.
DocID();
255 System.Diagnostics.Debug.Assert(docID == - 1 || docID ==
DocIdSetIterator.NO_MORE_DOCS);
259 if (filterDocIdSet == null)
266 if (filterIter == null)
271 int filterDoc = filterIter.
NextDoc();
272 int scorerDoc = scorer.
Advance(filterDoc);
277 if (scorerDoc == filterDoc)
285 filterDoc = filterIter.NextDoc();
286 scorerDoc = scorer.
Advance(filterDoc);
288 else if (scorerDoc > filterDoc)
290 filterDoc = filterIter.Advance(scorerDoc);
294 scorerDoc = scorer.
Advance(filterDoc);
301 Query query = original;
302 for (
Query rewrittenQuery = query.
Rewrite(reader); rewrittenQuery != query; rewrittenQuery = query.
Rewrite(reader))
304 query = rewrittenQuery;
312 int deBasedDoc = doc - docStarts[n];
314 return weight.
Explain(subReaders[n], deBasedDoc);
317 private bool fieldSortDoTrackScores;
318 private bool fieldSortDoMaxScore;
332 public virtual void SetDefaultFieldSortScoring(
bool doTrackScores,
bool doMaxScore)
334 fieldSortDoTrackScores = doTrackScores;
335 fieldSortDoMaxScore = doMaxScore;
340 get {
return reader; }