lucene-pylucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r1757492 - in /lucene/pylucene/trunk/test: test_BooleanOr.py test_BooleanQuery.py
Date Wed, 24 Aug 2016 10:59:01 GMT
Author: vajda
Date: Wed Aug 24 10:59:01 2016
New Revision: 1757492

URL: http://svn.apache.org/viewvc?rev=1757492&view=rev
Log:
test_BooleanOr and test_BooleanQuery pass

Modified:
    lucene/pylucene/trunk/test/test_BooleanOr.py
    lucene/pylucene/trunk/test/test_BooleanQuery.py

Modified: lucene/pylucene/trunk/test/test_BooleanOr.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/test/test_BooleanOr.py?rev=1757492&r1=1757491&r2=1757492&view=diff
==============================================================================
--- lucene/pylucene/trunk/test/test_BooleanOr.py (original)
+++ lucene/pylucene/trunk/test/test_BooleanOr.py Wed Aug 24 10:59:01 2016
@@ -19,7 +19,6 @@ from org.apache.lucene.analysis.standard
 from org.apache.lucene.document import Document, Field, TextField
 from org.apache.lucene.index import Term
 from org.apache.lucene.search import BooleanClause, BooleanQuery, TermQuery
-from org.apache.lucene.util import Version
 
 
 class BooleanOrTestCase(PyLuceneTestCase):
@@ -70,50 +69,60 @@ class BooleanOrTestCase(PyLuceneTestCase
 
     def testFlat(self):
 
-        q = BooleanQuery()
-        q.add(BooleanClause(self.t1, BooleanClause.Occur.SHOULD))
-        q.add(BooleanClause(self.t2, BooleanClause.Occur.SHOULD))
-        q.add(BooleanClause(self.c1, BooleanClause.Occur.SHOULD))
-        q.add(BooleanClause(self.c2, BooleanClause.Occur.SHOULD))
+        b = BooleanQuery.Builder()
+        b.add(BooleanClause(self.t1, BooleanClause.Occur.SHOULD))
+        b.add(BooleanClause(self.t2, BooleanClause.Occur.SHOULD))
+        b.add(BooleanClause(self.c1, BooleanClause.Occur.SHOULD))
+        b.add(BooleanClause(self.c2, BooleanClause.Occur.SHOULD))
+        q = b.build()
         self.assertEqual(1, self.search(q))
 
     def testParenthesisMust(self):
 
-        q3 = BooleanQuery()
-        q3.add(BooleanClause(self.t1, BooleanClause.Occur.SHOULD))
-        q3.add(BooleanClause(self.t2, BooleanClause.Occur.SHOULD))
-        q4 = BooleanQuery()
-        q4.add(BooleanClause(self.c1, BooleanClause.Occur.MUST))
-        q4.add(BooleanClause(self.c2, BooleanClause.Occur.MUST))
-        q2 = BooleanQuery()
-        q2.add(q3, BooleanClause.Occur.SHOULD)
-        q2.add(q4, BooleanClause.Occur.SHOULD)
+        b3 = BooleanQuery.Builder()
+        b3.add(BooleanClause(self.t1, BooleanClause.Occur.SHOULD))
+        b3.add(BooleanClause(self.t2, BooleanClause.Occur.SHOULD))
+        q3 = b3.build()
+        b4 = BooleanQuery.Builder()
+        b4.add(BooleanClause(self.c1, BooleanClause.Occur.MUST))
+        b4.add(BooleanClause(self.c2, BooleanClause.Occur.MUST))
+        q4 = b4.build()
+        b2 = BooleanQuery.Builder()
+        b2.add(q3, BooleanClause.Occur.SHOULD)
+        b2.add(q4, BooleanClause.Occur.SHOULD)
+        q2 = b2.build()
         self.assertEqual(1, self.search(q2))
 
     def testParenthesisMust2(self):
 
-        q3 = BooleanQuery()
-        q3.add(BooleanClause(self.t1, BooleanClause.Occur.SHOULD))
-        q3.add(BooleanClause(self.t2, BooleanClause.Occur.SHOULD))
-        q4 = BooleanQuery()
-        q4.add(BooleanClause(self.c1, BooleanClause.Occur.SHOULD))
-        q4.add(BooleanClause(self.c2, BooleanClause.Occur.SHOULD))
-        q2 = BooleanQuery()
-        q2.add(q3, BooleanClause.Occur.SHOULD)
-        q2.add(q4, BooleanClause.Occur.MUST)
+        b3 = BooleanQuery.Builder()
+        b3.add(BooleanClause(self.t1, BooleanClause.Occur.SHOULD))
+        b3.add(BooleanClause(self.t2, BooleanClause.Occur.SHOULD))
+        q3 = b3.build()
+        b4 = BooleanQuery.Builder()
+        b4.add(BooleanClause(self.c1, BooleanClause.Occur.SHOULD))
+        b4.add(BooleanClause(self.c2, BooleanClause.Occur.SHOULD))
+        q4 = b4.build()
+        b2 = BooleanQuery.Builder()
+        b2.add(q3, BooleanClause.Occur.SHOULD)
+        b2.add(q4, BooleanClause.Occur.MUST)
+        q2 = b2.build()
         self.assertEqual(1, self.search(q2))
 
     def testParenthesisShould(self):
 
-        q3 = BooleanQuery()
-        q3.add(BooleanClause(self.t1, BooleanClause.Occur.SHOULD))
-        q3.add(BooleanClause(self.t2, BooleanClause.Occur.SHOULD))
-        q4 = BooleanQuery()
-        q4.add(BooleanClause(self.c1, BooleanClause.Occur.SHOULD))
-        q4.add(BooleanClause(self.c2, BooleanClause.Occur.SHOULD))
-        q2 = BooleanQuery()
-        q2.add(q3, BooleanClause.Occur.SHOULD)
-        q2.add(q4, BooleanClause.Occur.SHOULD)
+        b3 = BooleanQuery.Builder()
+        b3.add(BooleanClause(self.t1, BooleanClause.Occur.SHOULD))
+        b3.add(BooleanClause(self.t2, BooleanClause.Occur.SHOULD))
+        q3 = b3.build()
+        b4 = BooleanQuery.Builder()
+        b4.add(BooleanClause(self.c1, BooleanClause.Occur.SHOULD))
+        b4.add(BooleanClause(self.c2, BooleanClause.Occur.SHOULD))
+        q4 = b4.build()
+        b2 = BooleanQuery.Builder()
+        b2.add(q3, BooleanClause.Occur.SHOULD)
+        b2.add(q4, BooleanClause.Occur.SHOULD)
+        q2 = b2.build()
         self.assertEqual(1, self.search(q2))
 
 

Modified: lucene/pylucene/trunk/test/test_BooleanQuery.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/test/test_BooleanQuery.py?rev=1757492&r1=1757491&r2=1757492&view=diff
==============================================================================
--- lucene/pylucene/trunk/test/test_BooleanQuery.py (original)
+++ lucene/pylucene/trunk/test/test_BooleanQuery.py Wed Aug 24 10:59:01 2016
@@ -26,24 +26,29 @@ class TestBooleanQuery(PyLuceneTestCase)
 
     def testEquality(self):
 
-        bq1 = BooleanQuery()
-        bq1.add(TermQuery(Term("field", "value1")), BooleanClause.Occur.SHOULD)
-        bq1.add(TermQuery(Term("field", "value2")), BooleanClause.Occur.SHOULD)
-
-        nested1 = BooleanQuery()
-        nested1.add(TermQuery(Term("field", "nestedvalue1")), BooleanClause.Occur.SHOULD)
-        nested1.add(TermQuery(Term("field", "nestedvalue2")), BooleanClause.Occur.SHOULD)
-        bq1.add(nested1, BooleanClause.Occur.SHOULD)
-
-        bq2 = BooleanQuery()
-        bq2.add(TermQuery(Term("field", "value1")), BooleanClause.Occur.SHOULD)
-        bq2.add(TermQuery(Term("field", "value2")), BooleanClause.Occur.SHOULD)
-
-        nested2 = BooleanQuery()
-        nested2.add(TermQuery(Term("field", "nestedvalue1")), BooleanClause.Occur.SHOULD)
-        nested2.add(TermQuery(Term("field", "nestedvalue2")), BooleanClause.Occur.SHOULD)
-        bq2.add(nested2, BooleanClause.Occur.SHOULD)
-        
+        b1 = BooleanQuery.Builder()
+        b1.add(TermQuery(Term("field", "value1")), BooleanClause.Occur.SHOULD)
+        b1.add(TermQuery(Term("field", "value2")), BooleanClause.Occur.SHOULD)
+        bq1 = b1.build()
+
+        n1 = BooleanQuery.Builder()
+        n1.add(TermQuery(Term("field", "nestedvalue1")), BooleanClause.Occur.SHOULD)
+        n1.add(TermQuery(Term("field", "nestedvalue2")), BooleanClause.Occur.SHOULD)
+        nested1 = n1.build()
+        b1.add(nested1, BooleanClause.Occur.SHOULD)
+        bq1 = b1.build()
+
+        b2 = BooleanQuery.Builder()
+        b2.add(TermQuery(Term("field", "value1")), BooleanClause.Occur.SHOULD)
+        b2.add(TermQuery(Term("field", "value2")), BooleanClause.Occur.SHOULD)
+
+        n2 = BooleanQuery.Builder()
+        n2.add(TermQuery(Term("field", "nestedvalue1")), BooleanClause.Occur.SHOULD)
+        n2.add(TermQuery(Term("field", "nestedvalue2")), BooleanClause.Occur.SHOULD)
+        nested2 = n2.build()
+        b2.add(nested2, BooleanClause.Occur.SHOULD)
+        bq2 = b2.build()
+
         self.assert_(bq1.equals(bq2))
 
 



Mime
View raw message