LUCENE-1599: missed SpanFirstQuery#clone and setting boost on clones

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@791302 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2009-07-05 19:09:01 +00:00
parent 405b71fd70
commit 9689ddf9e8
4 changed files with 14 additions and 3 deletions

View File

@ -28,7 +28,7 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.util.ToStringUtils;
/** Matches spans near the beginning of a field. */
public class SpanFirstQuery extends SpanQuery {
public class SpanFirstQuery extends SpanQuery implements Cloneable {
private SpanQuery match;
private int end;
@ -64,6 +64,12 @@ public class SpanFirstQuery extends SpanQuery {
return buffer.toString();
}
public Object clone() {
SpanFirstQuery spanFirstQuery = new SpanFirstQuery((SpanQuery) match.clone(), end);
spanFirstQuery.setBoost(getBoost());
return spanFirstQuery;
}
public void extractTerms(Set terms) {
match.extractTerms(terms);
}

View File

@ -160,7 +160,9 @@ public class SpanNearQuery extends SpanQuery implements Cloneable {
SpanQuery clause = (SpanQuery) clauses.get(i);
newClauses[i] = (SpanQuery) clause.clone();
}
return new SpanNearQuery(newClauses, slop, inOrder);
SpanNearQuery spanNearQuery = new SpanNearQuery(newClauses, slop, inOrder);
spanNearQuery.setBoost(getBoost());
return spanNearQuery;
}
/** Returns true iff <code>o</code> is equal to this. */

View File

@ -69,7 +69,9 @@ public class SpanNotQuery extends SpanQuery implements Cloneable {
}
public Object clone() {
return new SpanNotQuery((SpanQuery)include.clone(),(SpanQuery) exclude.clone());
SpanNotQuery spanNotQuery = new SpanNotQuery((SpanQuery)include.clone(),(SpanQuery) exclude.clone());
spanNotQuery.setBoost(getBoost());
return spanNotQuery;
}
public Spans getSpans(final IndexReader reader) throws IOException {

View File

@ -89,6 +89,7 @@ public class SpanOrQuery extends SpanQuery implements Cloneable {
newClauses[i] = (SpanQuery) clause.clone();
}
SpanOrQuery soq = new SpanOrQuery(newClauses);
soq.setBoost(getBoost());
return soq;
}