mirror of https://github.com/apache/lucene.git
test added that demonstrates an already fixed bug in
PhraseScorer of 1.4rc2 git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150295 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
91b461f5a0
commit
82dc3d50a3
|
@ -38,9 +38,21 @@ public class TestPhraseQuery extends TestCase {
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
RAMDirectory directory = new RAMDirectory();
|
RAMDirectory directory = new RAMDirectory();
|
||||||
IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true);
|
IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true);
|
||||||
|
|
||||||
Document doc = new Document();
|
Document doc = new Document();
|
||||||
doc.add(Field.Text("field", "one two three four five"));
|
doc.add(Field.Text("field", "one two three four five"));
|
||||||
writer.addDocument(doc);
|
writer.addDocument(doc);
|
||||||
|
|
||||||
|
doc = new Document();
|
||||||
|
doc.add(new Field("source", "marketing info", true, true, true));
|
||||||
|
writer.addDocument(doc);
|
||||||
|
|
||||||
|
doc = new Document();
|
||||||
|
doc.add(new Field("contents", "foobar", true, true, true));
|
||||||
|
doc.add(new Field("source", "marketing info", true, true, true));
|
||||||
|
writer.addDocument(doc);
|
||||||
|
|
||||||
|
writer.optimize();
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
||||||
searcher = new IndexSearcher(directory);
|
searcher = new IndexSearcher(directory);
|
||||||
|
@ -172,4 +184,18 @@ public class TestPhraseQuery extends TestCase {
|
||||||
|
|
||||||
searcher.close();
|
searcher.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testPhraseQueryInConjunctionScorer() throws Exception {
|
||||||
|
query.add(new Term("source", "marketing"));
|
||||||
|
query.add(new Term("source", "info"));
|
||||||
|
Hits hits = searcher.search(query);
|
||||||
|
assertEquals(2, hits.length());
|
||||||
|
|
||||||
|
TermQuery termQuery = new TermQuery(new Term("contents","foobar"));
|
||||||
|
BooleanQuery booleanQuery = new BooleanQuery();
|
||||||
|
booleanQuery.add(termQuery, true, false);
|
||||||
|
booleanQuery.add(query, true, false);
|
||||||
|
hits = searcher.search(booleanQuery);
|
||||||
|
assertEquals(1, hits.length());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue