LUCENE-7284: GapSpans needs to implement positionsCost()

This commit is contained in:
Alan Woodward 2016-05-17 12:04:46 +01:00
parent 1c7777cc55
commit cfc13f5b67
3 changed files with 26 additions and 3 deletions

View File

@ -118,6 +118,9 @@ Bug Fixes
* LUCENE-7279: JapaneseTokenizer throws ArrayIndexOutOfBoundsException
on some valid inputs (Mike McCandless)
* LUCENE-7284: GapSpans needs to implement positionsCost(). (Daniel Bigham, Alan
Woodward)
Documentation
* LUCENE-7223: Improve XXXPoint javadocs to make it clear that you

View File

@ -386,7 +386,7 @@ public class SpanNearQuery extends SpanQuery implements Cloneable {
@Override
public float positionsCost() {
throw new UnsupportedOperationException();
return 0;
}
}

View File

@ -29,6 +29,7 @@ import org.apache.lucene.search.CheckHits;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.Weight;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
@ -72,7 +73,8 @@ public class TestNearSpansOrdered extends LuceneTestCase {
"w1 xx w2 yy w3",
"w1 w3 xx w2 yy w3 zz",
"t1 t2 t2 t1",
"g x x g g x x x g g x x g"
"g x x g g x x x g g x x g",
"go to webpage"
};
protected SpanNearQuery makeQuery(String s1, String s2, String s3,
@ -292,6 +294,23 @@ public class TestNearSpansOrdered extends LuceneTestCase {
assertFinished(spans);
}
public void testNestedGaps() throws Exception {
SpanQuery q = SpanNearQuery.newOrderedNearQuery(FIELD)
.addClause(new SpanOrQuery(
new SpanTermQuery(new Term(FIELD, "open")),
SpanNearQuery.newOrderedNearQuery(FIELD)
.addClause(new SpanTermQuery(new Term(FIELD, "go")))
.addGap(1)
.build()
))
.addClause(new SpanTermQuery(new Term(FIELD, "webpage")))
.build();
TopDocs topDocs = searcher.search(q, 1);
assertEquals(6, topDocs.scoreDocs[0].doc);
}
/*
protected String[] docFields = {
"w1 w2 w3 w4 w5",
@ -299,7 +318,8 @@ public class TestNearSpansOrdered extends LuceneTestCase {
"w1 xx w2 yy w3",
"w1 w3 xx w2 yy w3 zz",
"t1 t2 t2 t1",
"g x x g g x x x g g x x g"
"g x x g g x x x g g x x g",
"go to webpage"
};
*/
}