mirror of https://github.com/apache/lucene.git
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:
parent
f35a93ef67
commit
2e7f226afe
|
@ -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
|
||||
|
|
|
@ -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++){
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue