LUCENE-4970: Fix boost value of rewritten NGramPhraseQuery.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1478225 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrien Grand 2013-05-01 22:59:45 +00:00
parent f35a93ef67
commit 2e7f226afe
3 changed files with 15 additions and 0 deletions

View File

@ -73,6 +73,9 @@ Bug Fixes
the child query has no hits, more aggressively catch cases where childQuery
incorrectly matches parent documents (Mike McCandless)
* LUCENE-4970: Fix boost value of rewritten NGramPhraseQuery.
(Shingo Sasaki via Adrien Grand)
Optimizations
* LUCENE-4938: Don't use an unnecessarily large priority queue in IndexSearcher

View File

@ -64,6 +64,7 @@ public class NGramPhraseQuery extends PhraseQuery {
// now create the new optimized phrase query for n-gram
PhraseQuery optimized = new PhraseQuery();
optimized.setBoost(getBoost());
int pos = 0;
final int lastPos = terms.length - 1;
for(int i = 0; i < terms.length; i++){

View File

@ -88,6 +88,17 @@ public class TestNGramPhraseQuery extends LuceneTestCase {
pq3 = (PhraseQuery)q;
assertArrayEquals(new Term[]{new Term("f", "ABC"), new Term("f", "DEF"), new Term("f", "FGH")}, pq3.getTerms());
assertArrayEquals(new int[]{0, 3, 5}, pq3.getPositions());
// LUCENE-4970: boosting test
PhraseQuery pq4 = new NGramPhraseQuery(2);
pq4.add(new Term("f", "AB"));
pq4.add(new Term("f", "BC"));
pq4.add(new Term("f", "CD"));
pq4.setBoost(100.0F);
q = pq4.rewrite(reader);
assertNotSame(pq4, q);
assertEquals(pq4.getBoost(), q.getBoost(), 0.1f);
}
}