Methods Summary |
---|
public void | add(org.apache.lucene.search.Query query)Add a subquery to this disjunction
disjuncts.add(query);
|
public void | add(java.util.Collection disjuncts)Add a collection of disjuncts to this disjunction
via Iterable
this.disjuncts.addAll(disjuncts);
|
public java.lang.Object | clone()Create a shallow copy of us -- used in rewriting if necessary
DisjunctionMaxQuery clone = (DisjunctionMaxQuery)super.clone();
clone.disjuncts = (ArrayList)this.disjuncts.clone();
return clone;
|
protected org.apache.lucene.search.Weight | createWeight(org.apache.lucene.search.Searcher searcher)
return new DisjunctionMaxWeight(searcher);
|
public boolean | equals(java.lang.Object o)Return true iff we represent the same query as o
if (! (o instanceof DisjunctionMaxQuery) ) return false;
DisjunctionMaxQuery other = (DisjunctionMaxQuery)o;
return this.getBoost() == other.getBoost()
&& this.tieBreakerMultiplier == other.tieBreakerMultiplier
&& this.disjuncts.equals(other.disjuncts);
|
public void | extractTerms(java.util.Set terms)
for (int i = 0; i < disjuncts.size(); i++) {
((Query)disjuncts.get(i)).extractTerms(terms);
}
|
public int | hashCode()Compute a hash code for hashing us
return Float.floatToIntBits(getBoost())
+ Float.floatToIntBits(tieBreakerMultiplier)
+ disjuncts.hashCode();
|
public java.util.Iterator | iterator()An Iterator over the disjuncts
return disjuncts.iterator();
|
public org.apache.lucene.search.Query | rewrite(org.apache.lucene.index.IndexReader reader)Optimize our representation and our subqueries representations
if (disjuncts.size() == 1) {
Query singleton = (Query) disjuncts.get(0);
Query result = singleton.rewrite(reader);
if (getBoost() != 1.0f) {
if (result == singleton) result = (Query)result.clone();
result.setBoost(getBoost() * result.getBoost());
}
return result;
}
DisjunctionMaxQuery clone = null;
for (int i = 0 ; i < disjuncts.size(); i++) {
Query clause = (Query) disjuncts.get(i);
Query rewrite = clause.rewrite(reader);
if (rewrite != clause) {
if (clone == null) clone = (DisjunctionMaxQuery)this.clone();
clone.disjuncts.set(i, rewrite);
}
}
if (clone != null) return clone;
else return this;
|
public java.lang.String | toString(java.lang.String field)Prettyprint us.
StringBuffer buffer = new StringBuffer();
buffer.append("(");
for (int i = 0 ; i < disjuncts.size(); i++) {
Query subquery = (Query) disjuncts.get(i);
if (subquery instanceof BooleanQuery) { // wrap sub-bools in parens
buffer.append("(");
buffer.append(subquery.toString(field));
buffer.append(")");
}
else buffer.append(subquery.toString(field));
if (i != disjuncts.size()-1) buffer.append(" | ");
}
buffer.append(")");
if (tieBreakerMultiplier != 0.0f) {
buffer.append("~");
buffer.append(tieBreakerMultiplier);
}
if (getBoost() != 1.0) {
buffer.append("^");
buffer.append(getBoost());
}
return buffer.toString();
|