You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by yo...@apache.org on 2007/09/26 05:25:32 UTC
svn commit: r579445 -
/lucene/solr/trunk/src/java/org/apache/solr/search/function/BoostedQuery.java
Author: yonik
Date: Tue Sep 25 20:25:30 2007
New Revision: 579445
URL: http://svn.apache.org/viewvc?rev=579445&view=rev
Log:
fix BoostedQuery.rewrite
Modified:
lucene/solr/trunk/src/java/org/apache/solr/search/function/BoostedQuery.java
Modified: lucene/solr/trunk/src/java/org/apache/solr/search/function/BoostedQuery.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/function/BoostedQuery.java?rev=579445&r1=579444&r2=579445&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/function/BoostedQuery.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/function/BoostedQuery.java Tue Sep 25 20:25:30 2007
@@ -40,7 +40,11 @@
public ValueSource getValueSource() { return boostVal; }
public Query rewrite(IndexReader reader) throws IOException {
- return q.rewrite(reader);
+ Query newQ = q.rewrite(reader);
+ if (newQ == q) return this;
+ BoostedQuery bq = (BoostedQuery)this.clone();
+ bq.q = newQ;
+ return bq;
}
public void extractTerms(Set terms) {
@@ -53,12 +57,11 @@
private class BoostedWeight implements Weight {
Searcher searcher;
- Weight weight;
- boolean qStrict;
+ Weight qWeight;
public BoostedWeight(Searcher searcher) throws IOException {
this.searcher = searcher;
- this.weight = q.weight(searcher);
+ this.qWeight = q.weight(searcher);
}
public Query getQuery() {
@@ -70,18 +73,18 @@
}
public float sumOfSquaredWeights() throws IOException {
- float sum = weight.sumOfSquaredWeights();
+ float sum = qWeight.sumOfSquaredWeights();
sum *= getBoost() * getBoost();
return sum ;
}
public void normalize(float norm) {
norm *= getBoost();
- weight.normalize(norm);
+ qWeight.normalize(norm);
}
public Scorer scorer(IndexReader reader) throws IOException {
- Scorer subQueryScorer = weight.scorer(reader);
+ Scorer subQueryScorer = qWeight.scorer(reader);
return new BoostedQuery.CustomScorer(getSimilarity(searcher), reader, this, subQueryScorer, boostVal);
}
@@ -125,7 +128,7 @@
}
public Explanation explain(int doc) throws IOException {
- Explanation subQueryExpl = weight.weight.explain(reader,doc);
+ Explanation subQueryExpl = weight.qWeight.explain(reader,doc);
if (!subQueryExpl.isMatch()) {
return subQueryExpl;
}