make ConstantWeight serializable: LUCENE-515

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@384407 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2006-03-09 02:42:13 +00:00
parent 04ca37fb49
commit 020ab2dbdf
4 changed files with 309 additions and 296 deletions

View File

@ -9,6 +9,9 @@ Bug fixes
1. LUCENE-330: Fix issue of FilteredQuery not working properly within
BooleanQuery. (Paul Elschot via Erik Hatcher)
2. LUCENE-515: Make ConstantScoreRangeQuery and ConstantScoreQuery work
with RemoteSearchable. (Philippe Laflamme via Yonik Seeley)
1.9.1
Bug fixes

View File

@ -40,12 +40,12 @@ public class ConstantScoreQuery extends Query {
}
protected class ConstantWeight implements Weight {
private Searcher searcher;
private Similarity similarity;
private float queryNorm;
private float queryWeight;
public ConstantWeight(Searcher searcher) {
this.searcher = searcher;
this.similarity = getSimilarity(searcher);
}
public Query getQuery() {
@ -67,7 +67,7 @@ public class ConstantScoreQuery extends Query {
}
public Scorer scorer(IndexReader reader) throws IOException {
return new ConstantScorer(getSimilarity(searcher), reader, this);
return new ConstantScorer(similarity, reader, this);
}
public Explanation explain(IndexReader reader, int doc) throws IOException {

View File

@ -107,4 +107,14 @@ public class TestRemoteSearchable extends TestCase {
new QueryFilter(new TermQuery(new Term("test", "non-existent-term"))));
assertEquals(0, nohits.length());
}
public void testConstantScoreQuery() throws Exception {
// try to search the published index
Searchable[] searchables = { getRemote() };
Searcher searcher = new MultiSearcher(searchables);
Hits hits = searcher.search(
new ConstantScoreQuery(new QueryFilter(
new TermQuery(new Term("test", "test")))));
assertEquals(1, hits.length());
}
}