lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o...@apache.org
Subject cvs commit: jakarta-lucene/src/test/org/apache/lucene/search TestPhraseQuery.java
Date Thu, 05 Feb 2004 13:17:26 GMT
otis        2004/02/05 05:17:26

  Modified:    src/test/org/apache/lucene/search TestPhraseQuery.java
  Log:
  - Applied a small patch from Grant Ingersoll.
    The code moved from TestStopAnalyzer.java
  
  Revision  Changes    Path
  1.3       +29 -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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestPhraseQuery.java	21 Sep 2003 13:41:59 -0000	1.2
  +++ TestPhraseQuery.java	5 Feb 2004 13:17:26 -0000	1.3
  @@ -56,6 +56,7 @@
   
   import junit.framework.TestCase;
   import org.apache.lucene.analysis.WhitespaceAnalyzer;
  +import org.apache.lucene.analysis.StopAnalyzer;
   import org.apache.lucene.document.Document;
   import org.apache.lucene.document.Field;
   import org.apache.lucene.index.IndexWriter;
  @@ -180,5 +181,33 @@
       query.setSlop(6);
       hits = searcher.search(query);
       assertEquals("slop of 6 just right", 1, hits.length());
  +  }
  +  
  +  public void testPhraseQueryWithStopAnalyzer() throws Exception {
  +    RAMDirectory directory = new RAMDirectory();
  +    StopAnalyzer stopAnalyzer = new StopAnalyzer();
  +    IndexWriter writer = new IndexWriter(directory, stopAnalyzer, true);
  +    Document doc = new Document();
  +    doc.add(Field.Text("field", "the stop words are here"));
  +    writer.addDocument(doc);
  +    writer.close();
  +
  +    IndexSearcher searcher = new IndexSearcher(directory);
  +
  +    // valid exact phrase query
  +    PhraseQuery query = new PhraseQuery();
  +    query.add(new Term("field","stop"));
  +    query.add(new Term("field","words"));
  +    Hits hits = searcher.search(query);
  +    assertEquals(1, hits.length());
  +
  +    // currently StopAnalyzer does not leave "holes", so this matches.
  +    query = new PhraseQuery();
  +    query.add(new Term("field", "words"));
  +    query.add(new Term("field", "here"));
  +    hits = searcher.search(query);
  +    assertEquals(1, hits.length());
  +
  +    searcher.close();
     }
   }
  
  
  

---------------------------------------------------------------------
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