20 using Lucene.Net.Index;
21 using Lucene.Net.Support;
24 using Query = Lucene.Net.Search.Query;
26 namespace Lucene.Net.Search.Spans
36 protected internal System.Collections.Generic.IList<
SpanQuery> clauses;
37 protected internal int internalSlop;
38 protected internal bool inOrder;
40 protected internal System.String internalField;
41 private readonly
bool collectPayloads;
56 this.clauses =
new System.Collections.Generic.List<
SpanQuery>(clauses.Length);
57 for (
int i = 0; i < clauses.Length; i++)
63 internalField = clause.
Field;
65 else if (!clause.
Field.Equals(internalField))
67 throw new System.ArgumentException(
"Clauses must have same field.");
69 this.clauses.Add(clause);
71 this.collectPayloads = collectPayloads;
72 this.internalSlop = slop;
73 this.inOrder = inOrder;
80 return clauses.ToArray();
84 public virtual int Slop
86 get {
return internalSlop; }
90 public virtual bool IsInOrder
92 get {
return inOrder; }
95 public override string Field
97 get {
return internalField; }
100 public override void ExtractTerms(System.Collections.Generic.ISet<
Term> terms)
108 public override System.String ToString(System.String field)
110 System.Text.StringBuilder buffer =
new System.Text.StringBuilder();
111 buffer.Append(
"spanNear([");
112 System.Collections.Generic.IEnumerator<
SpanQuery> i = clauses.GetEnumerator();
116 buffer.Append(clause.
ToString(field));
119 if (clauses.Count > 0) buffer.Length -= 2;
120 buffer.Append(
"], ");
121 buffer.Append(internalSlop);
123 buffer.Append(inOrder);
131 if (clauses.Count == 0)
133 return new SpanOrQuery(GetClauses()).GetSpans(reader);
135 if (clauses.Count == 1)
137 return clauses[0].GetSpans(reader);
145 for (
int i = 0; i < clauses.Count; i++)
154 clone.clauses[i] = query;
167 public override System.Object Clone()
169 int sz = clauses.Count;
172 for (
int i = 0; i < sz; i++)
178 spanNearQuery.
Boost = Boost;
179 return spanNearQuery;
183 public override bool Equals(System.Object o)
192 if (inOrder != spanNearQuery.inOrder)
194 if (internalSlop != spanNearQuery.internalSlop)
196 if (clauses.Count != spanNearQuery.clauses.Count)
198 System.Collections.IEnumerator iter1 = clauses.GetEnumerator();
199 System.Collections.IEnumerator iter2 = spanNearQuery.clauses.GetEnumerator();
200 while (iter1.MoveNext() && iter2.MoveNext())
208 return Boost == spanNearQuery.
Boost;
211 public override int GetHashCode()
224 result += System.Convert.ToInt32(Boost);
225 result += internalSlop;
226 result ^= (inOrder ? (long) 0x99AFD3BD : 0);