20 using Lucene.Net.Index;
23 namespace Lucene.Net.Search
47 public abstract class Query : System.ICloneable
49 private float boost = 1.0f;
55 public virtual float Boost
58 set { boost = value; }
75 public abstract System.String ToString(System.String field);
78 public override System.String ToString()
90 throw new System.NotSupportedException();
99 float norm = GetSimilarity(searcher).QueryNorm(sum);
100 if (
float.IsInfinity(norm) ||
float.IsNaN(norm))
130 var uniques =
new System.Collections.Generic.HashSet<
Query>();
131 for (
int i = 0; i < queries.Length; i++)
133 Query query = queries[i];
142 for (
int j = 0; splittable && j < clauses.Length; j++)
144 splittable = (clauses[j].
Occur ==
Occur.SHOULD);
149 for (
int j = 0; j < clauses.Length; j++)
151 uniques.Add(clauses[j].
Query);
160 if (uniques.Count == 1)
162 return uniques.First();
165 foreach (
Query key
in uniques)
167 result.Add(key,
Occur.SHOULD);
178 public virtual void ExtractTerms(System.Collections.Generic.ISet<
Term> terms)
181 throw new System.NotSupportedException();
193 var allClauses =
new System.Collections.Generic.HashSet<
BooleanClause>();
198 allClauses.Add(clause);
202 bool coordDisabled = queries.Length == 0?
false:queries[0].IsCoordDisabled();
223 public virtual System.Object Clone()
227 return base.MemberwiseClone();
229 catch (System.Exception e)
231 throw new System.SystemException(
"Clone not supported: " + e.Message);
235 public override int GetHashCode()
239 result = prime * result + BitConverter.ToInt32(BitConverter.GetBytes(boost), 0);
243 public override bool Equals(System.Object obj)
249 if (GetType() != obj.GetType())
252 if (BitConverter.ToInt32(BitConverter.GetBytes(boost), 0) != BitConverter.ToInt32(BitConverter.GetBytes(other.boost), 0))