lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r805185 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/search/QueryWrapperFilter.java src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
Date Mon, 17 Aug 2009 22:22:00 GMT
Author: markrmiller
Date: Mon Aug 17 22:22:00 2009
New Revision: 805185

URL: http://svn.apache.org/viewvc?rev=805185&view=rev
Log:
LUCENE-1818: QueryWrapperFilter using createWeight rather than weight

Added:
    lucene/java/trunk/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/search/QueryWrapperFilter.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=805185&r1=805184&r2=805185&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Mon Aug 17 22:22:00 2009
@@ -61,7 +61,8 @@
     Going forward Searchable will be kept for convenience only and may
     be changed between minor releases without any deprecation
     process. It is not recommended that you implement it, but rather extend
-    Searcher.  (Shai Erera, Chris Hostetter, Mark Miller via Mike McCandless)
+    Searcher.  
+    (Shai Erera, Chris Hostetter, Martin Ruckli, Mark Miller via Mike McCandless)
 
  4. LUCENE-1422, LUCENE-1693: The new TokenStream API (see below) using
     Attributes has some backwards breaks in rare cases.
@@ -320,7 +321,7 @@
     out of order when used with a Collector that can accept docs out of order.
     Finally, Weight#explain now also takes a the top-level searcher, sub-reader 
     and sub-docID.
-    (Shai Erera, Chris Hostetter, Mark Miller via Mike McCandless)
+    (Shai Erera, Chris Hostetter, Martin Ruckli, Mark Miller via Mike McCandless)
  	
 25. LUCENE-1466: Changed Tokenizer.input to be a CharStream; added
     CharFilter and MappingCharFilter, which allows chaining & mapping

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/QueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/QueryWrapperFilter.java?rev=805185&r1=805184&r2=805185&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/QueryWrapperFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/QueryWrapperFilter.java Mon Aug 17
22:22:00 2009
@@ -69,7 +69,7 @@
   }
   
   public DocIdSet getDocIdSet(final IndexReader reader) throws IOException {
-    final Weight weight = query.createWeight(new IndexSearcher(reader));
+    final Weight weight = query.weight(new IndexSearcher(reader));
     return new DocIdSet() {
       public DocIdSetIterator iterator() throws IOException {
         return weight.scorer(reader, true, false);

Added: lucene/java/trunk/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java?rev=805185&view=auto
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java (added)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java Mon Aug
17 22:22:00 2009
@@ -0,0 +1,53 @@
+package org.apache.lucene.search;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.Field.Index;
+import org.apache.lucene.document.Field.Store;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BooleanClause.Occur;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.LuceneTestCase;
+
+public class TestQueryWrapperFilter extends LuceneTestCase {
+
+  public void testBasic() throws Exception {
+    Directory dir = new RAMDirectory();
+    IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true,
+        IndexWriter.MaxFieldLength.LIMITED);
+    Document doc = new Document();
+    doc.add(new Field("field", "value", Store.NO, Index.ANALYZED));
+    writer.addDocument(doc);
+    writer.close();
+
+    TermQuery termQuery = new TermQuery(new Term("field", "value"));
+
+    // should not throw exception with primitive query
+    QueryWrapperFilter qwf = new QueryWrapperFilter(termQuery);
+
+    IndexSearcher searcher = new IndexSearcher(dir, true);
+    TopDocs hits = searcher.search(new MatchAllDocsQuery(), qwf, 10);
+    assertEquals(1, hits.totalHits);
+
+    // should not throw exception with non primitive query
+    BooleanQuery booleanQuery = new BooleanQuery();
+    booleanQuery.add(termQuery, Occur.MUST);
+    booleanQuery.add(new TermQuery(new Term("field", "missing")),
+        Occur.MUST_NOT);
+    qwf = new QueryWrapperFilter(termQuery);
+
+    hits = searcher.search(new MatchAllDocsQuery(), qwf, 10);
+    assertEquals(1, hits.totalHits);
+
+    // should not throw exception with Query that doesn't implement
+    // Query#createWeight
+    qwf = new QueryWrapperFilter(new FuzzyQuery(new Term("field", "valu")));
+
+    hits = searcher.search(new MatchAllDocsQuery(), qwf, 10);
+    assertEquals(1, hits.totalHits);
+
+  }
+}



Mime
View raw message