Ejemplo n.º 1
0
 def testTwoTerms(self):
     expected = CQL_QUERY(
         SCOPED_CLAUSE(
             SCOPED_CLAUSE(SEARCH_CLAUSE(SEARCH_TERM(TERM('term1'))), ),
             BOOLEAN('and'), SEARCH_CLAUSE(SEARCH_TERM(TERM('term2')))))
     r = parseString('term1 and term2')
     self.assertEqualsCQL(expected, r)
Ejemplo n.º 2
0
 def testBooleansAreCaseInsensitive(self):
     self.assertEqualsCQL(
         CQL_QUERY(
             SCOPED_CLAUSE(
                 SCOPED_CLAUSE(SEARCH_CLAUSE(SEARCH_TERM(TERM('term')))),
                 BOOLEAN('and'),
                 SEARCH_CLAUSE(SEARCH_TERM(TERM('term2'))))),
         parseString('term AnD term2'))
Ejemplo n.º 3
0
 def testPrecedenceOrAnd(self):
     answer = CQL_QUERY(
         SCOPED_CLAUSE(
             SEARCH_CLAUSE(SEARCH_TERM(TERM('term1'))), BOOLEAN('or'),
             SCOPED_CLAUSE(
                 SCOPED_CLAUSE(SEARCH_CLAUSE(SEARCH_TERM(TERM('term2')))),
                 BOOLEAN('and'),
                 SEARCH_CLAUSE(SEARCH_TERM(TERM('term3'))))))
     self.assertEqualsCQL(answer, parseString('term1 or term2 and term3'))
Ejemplo n.º 4
0
 def testPrecedenceAndAndAnd(self):
     expected = CQL_QUERY(
         SCOPED_CLAUSE(
             SCOPED_CLAUSE(
                 SCOPED_CLAUSE(
                     SCOPED_CLAUSE(SEARCH_CLAUSE(SEARCH_TERM(TERM('a'))), ),
                     BOOLEAN('and'), SEARCH_CLAUSE(SEARCH_TERM(TERM('b')))),
                 BOOLEAN('and'), SEARCH_CLAUSE(SEARCH_TERM(TERM('c')))),
             BOOLEAN('and'), SEARCH_CLAUSE(SEARCH_TERM(TERM('d')))))
     r = parseString("a and b and c and d")
     self.assertEqualsCQL(expected, r)
Ejemplo n.º 5
0
 def testOneTerm(self):
     self.assertEqualsCQL(
         CQL_QUERY(SCOPED_CLAUSE(SEARCH_CLAUSE(SEARCH_TERM(TERM('term'))))),
         parseString('term'))
     self.assertEqualsCQL(
         CQL_QUERY(
             SCOPED_CLAUSE(SEARCH_CLAUSE(SEARCH_TERM(
                 TERM('white space'))))), parseString('"white space"'))
     self.assertEqualsCQL(
         CQL_QUERY(
             SCOPED_CLAUSE(
                 SEARCH_CLAUSE(SEARCH_TERM(TERM('string "quotes"'))))),
         parseString(r'"string \"quotes\""'))
Ejemplo n.º 6
0
 def testPrecedenceAndOr(self):
     answer = CQL_QUERY(
         SCOPED_CLAUSE(
             SEARCH_CLAUSE(
                 CQL_QUERY(
                     SCOPED_CLAUSE(
                         SCOPED_CLAUSE(
                             SEARCH_CLAUSE(SEARCH_TERM(TERM('term')))),
                         BOOLEAN('and'),
                         SEARCH_CLAUSE(SEARCH_TERM(TERM('term2')))))),
             BOOLEAN('or'),
             SCOPED_CLAUSE(SEARCH_CLAUSE(SEARCH_TERM(TERM('term3'))))))
     result = parseString('term and term2 or term3')
     self.assertEqualsCQL(answer, result)
Ejemplo n.º 7
0
 def testPrecedenceAndOr2(self):
     answer = CQL_QUERY(
         SCOPED_CLAUSE(
             SEARCH_CLAUSE(
                 CQL_QUERY(
                     SCOPED_CLAUSE(
                         SCOPED_CLAUSE(
                             SEARCH_CLAUSE(SEARCH_TERM(TERM('term')))),
                         BOOLEAN('and'),
                         SEARCH_CLAUSE(
                             parseString(
                                 'term2 and term3 and term4 and term5'))))),
             BOOLEAN('or'),
             SCOPED_CLAUSE(SEARCH_CLAUSE(SEARCH_TERM(TERM('term6'))))))
     r = parseString(
         'term and (term2 and term3 and term4 and term5) or term6')
     self.assertEqualsCQL(answer, r)
Ejemplo n.º 8
0
 def addFilter(self, field, term):
     self._addFilter(SEARCH_CLAUSE(
         INDEX(TERM(field)),
         RELATION(COMPARITOR('exact')),
         SEARCH_TERM(TERM(term))
     ))
Ejemplo n.º 9
0
 def addTermFilter(self, term):
     self._addFilter(SEARCH_CLAUSE(
         SEARCH_TERM(
             TERM(term)
         )
     ))