mirror of https://github.com/apache/lucene.git
Fixed a bug where boosting was lost.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149928 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a2042c190b
commit
a793838548
|
@ -162,8 +162,11 @@ public class BooleanQuery extends Query {
|
|||
protected Weight createWeight(Searcher searcher) {
|
||||
if (clauses.size() == 1) { // optimize 1-clause queries
|
||||
BooleanClause c = (BooleanClause)clauses.elementAt(0);
|
||||
if (!c.prohibited) // just return clause weight
|
||||
return c.query.createWeight(searcher);
|
||||
if (!c.prohibited) { // just return clause weight
|
||||
Query clone = (Query)c.query.clone();
|
||||
clone.setBoost(getBoost() * clone.getBoost());
|
||||
return clone.createWeight(searcher);
|
||||
}
|
||||
}
|
||||
return new BooleanWeight(searcher);
|
||||
}
|
||||
|
|
|
@ -210,6 +210,7 @@ public class PhrasePrefixQuery extends Query {
|
|||
for (int i=0; i<terms.length; i++) {
|
||||
boq.add(new TermQuery(terms[i]), false, false);
|
||||
}
|
||||
boq.setBoost(getBoost());
|
||||
return boq.createWeight(searcher);
|
||||
}
|
||||
return new PhrasePrefixWeight(searcher);
|
||||
|
|
|
@ -189,7 +189,9 @@ public class PhraseQuery extends Query {
|
|||
protected Weight createWeight(Searcher searcher) {
|
||||
if (terms.size() == 1) { // optimize one-term case
|
||||
Term term = (Term)terms.elementAt(0);
|
||||
return new TermQuery(term).createWeight(searcher);
|
||||
Query termQuery = new TermQuery(term);
|
||||
termQuery.setBoost(getBoost());
|
||||
return termQuery.createWeight(searcher);
|
||||
}
|
||||
return new PhraseWeight(searcher);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ import org.apache.lucene.index.IndexReader;
|
|||
<li>{@link org.apache.lucene.queryParser.QueryParser QueryParser}
|
||||
</ul>
|
||||
*/
|
||||
public abstract class Query implements java.io.Serializable {
|
||||
public abstract class Query implements java.io.Serializable, Cloneable {
|
||||
private float boost = 1.0f; // query boost factor
|
||||
|
||||
/** Sets the boost for this query clause to <code>b</code>. Documents
|
||||
|
@ -167,4 +167,12 @@ public abstract class Query implements java.io.Serializable {
|
|||
}
|
||||
|
||||
|
||||
/** Returns a clone of this query. */
|
||||
public Object clone() {
|
||||
try {
|
||||
return (Query)super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue