From 82dc3d50a3c737712c72f667443251337658607b Mon Sep 17 00:00:00 2001 From: Christoph Goller Date: Tue, 20 Apr 2004 13:39:08 +0000 Subject: [PATCH] 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 --- .../apache/lucene/search/TestPhraseQuery.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/org/apache/lucene/search/TestPhraseQuery.java b/src/test/org/apache/lucene/search/TestPhraseQuery.java index ba9b657620a..f1f91b014c1 100644 --- a/src/test/org/apache/lucene/search/TestPhraseQuery.java +++ b/src/test/org/apache/lucene/search/TestPhraseQuery.java @@ -38,9 +38,21 @@ public class TestPhraseQuery extends TestCase { public void setUp() throws Exception { RAMDirectory directory = new RAMDirectory(); IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true); + Document doc = new Document(); doc.add(Field.Text("field", "one two three four five")); 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(); searcher = new IndexSearcher(directory); @@ -172,4 +184,18 @@ public class TestPhraseQuery extends TestCase { 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()); + } }