19 using Lucene.Net.Index;
24 namespace Lucene.Net.Search
38 private System.String normsField;
44 this.normsField = normsField;
47 private class MatchAllScorer:
Scorer
51 this.enclosingInstance = enclosingInstance;
58 return enclosingInstance;
64 internal byte[] norms;
65 private int doc = - 1;
69 InitBlock(enclosingInstance);
70 this.termDocs = reader.
TermDocs(null);
75 public override int DocID()
80 public override int NextDoc()
82 return doc = termDocs.
Next()?termDocs.Doc:NO_MORE_DOCS;
85 public override float Score()
87 return norms == null?score:score *
Similarity.DecodeNorm(norms[DocID()]);
90 public override int Advance(
int target)
92 return doc = termDocs.SkipTo(target)?termDocs.Doc:NO_MORE_DOCS;
97 private class MatchAllDocsWeight:
Weight
101 this.enclosingInstance = enclosingInstance;
108 return enclosingInstance;
113 private float queryWeight;
114 private float queryNorm;
118 InitBlock(enclosingInstance);
119 this.similarity = searcher.Similarity;
122 public override System.String ToString()
124 return "weight(" + Enclosing_Instance +
")";
129 get {
return Enclosing_Instance; }
132 public override float Value
134 get {
return queryWeight; }
137 public override float GetSumOfSquaredWeights()
139 queryWeight = Enclosing_Instance.Boost;
140 return queryWeight*queryWeight;
143 public override void Normalize(
float queryNorm)
145 this.queryNorm = queryNorm;
146 queryWeight *= this.queryNorm;
151 return new MatchAllScorer(enclosingInstance, reader, similarity,
this, Enclosing_Instance.normsField != null?reader.
Norms(Enclosing_Instance.normsField):null);
158 if (Enclosing_Instance.Boost != 1.0f)
160 queryExpl.AddDetail(
new Explanation(Enclosing_Instance.Boost,
"boost"));
162 queryExpl.AddDetail(
new Explanation(queryNorm,
"queryNorm"));
170 return new MatchAllDocsWeight(
this, searcher);
173 public override void ExtractTerms(System.Collections.Generic.ISet<
Term> terms)
177 public override System.String ToString(System.String field)
179 System.Text.StringBuilder buffer =
new System.Text.StringBuilder();
180 buffer.Append(
"*:*");
182 return buffer.ToString();
185 public override bool Equals(System.Object o)
190 return this.Boost == other.
Boost;
193 public override int GetHashCode()
195 return BitConverter.ToInt32(BitConverter.GetBytes(Boost), 0) ^ 0x1AA71190;