Implements search over a single IndexReader.
///
/// Applications usually need only call the inherited {@link #Search(Query)}
/// or {@link #Search(Query,Filter)} methods. For performance reasons it is
/// recommended to open only one IndexSearcher and use it for all of your searches.
///
public class IndexSearcher : Searcher
{
private class AnonymousClassHitCollector : HitCollector
{
public AnonymousClassHitCollector(System.Collections.BitArray bits, int[] totalHits, Lucene.Net.Search.HitQueue hq, int nDocs, IndexSearcher enclosingInstance)
{
InitBlock(bits, totalHits, hq, nDocs, enclosingInstance);
}
private void InitBlock(System.Collections.BitArray bits, int[] totalHits, Lucene.Net.Search.HitQueue hq, int nDocs, IndexSearcher enclosingInstance)
{
this.bits = bits;
this.totalHits = totalHits;
this.hq = hq;
this.nDocs = nDocs;
this.enclosingInstance = enclosingInstance;
}
private System.Collections.BitArray bits;
private int[] totalHits;
private Lucene.Net.Search.HitQueue hq;
private int nDocs;
private IndexSearcher enclosingInstance;
public IndexSearcher Enclosing_Instance
{
get
{
return enclosingInstance;
}
}
private float minScore = 0.0f;
public override void Collect(int doc, float score)
{
if (score > 0.0f && (bits == null || bits.Get(doc)))
{
// skip docs not in bits
totalHits[0]++;
if (hq.Size() < nDocs || score >= minScore)
{
hq.Insert(new ScoreDoc(doc, score));
minScore = ((ScoreDoc) hq.Top()).score; // maintain minScore
}
}
}
}
private class AnonymousClassHitCollector1 : HitCollector
{
public AnonymousClassHitCollector1(System.Collections.BitArray bits, int[] totalHits, Lucene.Net.Search.FieldSortedHitQueue hq, IndexSearcher enclosingInstance)
{
InitBlock(bits, totalHits, hq, enclosingInstance);
}
private void InitBlock(System.Collections.BitArray bits, int[] totalHits, Lucene.Net.Search.FieldSortedHitQueue hq, IndexSearcher enclosingInstance)
{
this.bits = bits;
this.totalHits = totalHits;
this.hq = hq;
this.enclosingInstance = enclosingInstance;
}
private System.Collections.BitArray bits;
private int[] totalHits;
private Lucene.Net.Search.FieldSortedHitQueue hq;
private IndexSearcher enclosingInstance;
public IndexSearcher Enclosing_Instance
{
get
{
return enclosingInstance;
}
}
public override void Collect(int doc, float score)
{
if (score > 0.0f && (bits == null || bits.Get(doc)))
{
// skip docs not in bits
totalHits[0]++;
hq.Insert(new FieldDoc(doc, score));
}
}
}
private class AnonymousClassHitCollector2 : HitCollector
{
public AnonymousClassHitCollector2(System.Collections.BitArray bits, Lucene.Net.Search.HitCollector results, IndexSearcher enclosingInstance)
{
InitBlock(bits, results, enclosingInstance);
}
private void InitBlock(System.Collections.BitArray bits, Lucene.Net.Search.HitCollector results, IndexSearcher enclosingInstance)
{
this.bits = bits;
this.results = results;
this.enclosingInstance = enclosingInstance;
}
private System.Collections.BitArray bits;
private Lucene.Net.Search.HitCollector results;
private IndexSearcher enclosingInstance;
public IndexSearcher Enclosing_Instance
{
get
{
return enclosingInstance;
}
}
public override void Collect(int doc, float score)
{
if (bits.Get(doc))
{
// skip docs not in bits
results.Collect(doc, score);
}
}
}
public /*internal*/ IndexReader reader;
private bool closeReader;
///