lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gol...@apache.org
Subject cvs commit: jakarta-lucene/src/test/org/apache/lucene/search TestPhraseQuery.java
Date Tue, 20 Apr 2004 13:39:08 GMT
goller      2004/04/20 06:39:08

  Modified:    src/test/org/apache/lucene/search TestPhraseQuery.java
  Log:
  test added that demonstrates an already fixed bug in
  PhraseScorer of 1.4rc2
  
  Revision  Changes    Path
  1.5       +26 -0     jakarta-lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java
  
  Index: TestPhraseQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestPhraseQuery.java	29 Mar 2004 22:48:06 -0000	1.4
  +++ TestPhraseQuery.java	20 Apr 2004 13:39:08 -0000	1.5
  @@ -38,9 +38,21 @@
     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);
  @@ -171,5 +183,19 @@
       assertEquals(1, hits.length());
   
       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());
     }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message