lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1640369 - in /lucene/dev/branches/branch_5x: ./ lucene/ lucene/core/ lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java
Date Tue, 18 Nov 2014 15:34:02 GMT
Author: mikemccand
Date: Tue Nov 18 15:34:01 2014
New Revision: 1640369

URL: http://svn.apache.org/r1640369
Log:
add test

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/lucene/   (props changed)
    lucene/dev/branches/branch_5x/lucene/core/   (props changed)
    lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java?rev=1640369&r1=1640368&r2=1640369&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java
Tue Nov 18 15:34:01 2014
@@ -30,11 +30,11 @@ import org.apache.lucene.analysis.MockAn
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.MultiReader;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.Term;
@@ -390,4 +390,23 @@ public class TestBooleanQuery extends Lu
     dir.close();
   }
 
+  public void testMinShouldMatchLeniency() throws Exception {
+    Directory dir = newDirectory();
+    IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
+    Document doc = new Document();
+    doc.add(newTextField("field", "a b c d", Field.Store.NO));
+    w.addDocument(doc);
+    IndexReader r = DirectoryReader.open(w, true);
+    IndexSearcher s = newSearcher(r);
+    BooleanQuery bq = new BooleanQuery();
+    bq.add(new TermQuery(new Term("field", "a")), BooleanClause.Occur.SHOULD);
+    bq.add(new TermQuery(new Term("field", "b")), BooleanClause.Occur.SHOULD);
+
+    // No doc can match: BQ has only 2 clauses and we are asking for minShouldMatch=4
+    bq.setMinimumNumberShouldMatch(4);
+    assertEquals(0, s.search(bq, 1).totalHits);
+    r.close();
+    w.close();
+    dir.close();
+  }
 }



Mime
View raw message