def testUnsupportedCQL(self):
     printer=SolrLuceneQueryComposer(unqualifiedTermFields=[("all", 1)])
     ast = parseString("field any term")
     try:
         printer.compose(ast)
         self.fail("must raise UnsupportedCQL")
     except UnsupportedCQL, e:
         self.assertEquals("Only =, ==, exact, <, <=, > and >= are supported.", str(e))
示例#2
0
class Cql2SolrLuceneQuery(Observable, Logger):
    def __init__(self, unqualifiedFields, name=None):
        Observable.__init__(self, name=name)
        self._cqlComposer = SolrLuceneQueryComposer(unqualifiedFields)

    def executeQuery(self, cqlAbstractSyntaxTree, *args, **kwargs):
        filterQueries = kwargs.get('filterQueries', [])
        filterQueries = [self._convert(fq) for fq in filterQueries]
        response = yield self.any.executeQuery(luceneQueryString=self._convert(cqlAbstractSyntaxTree), *args, **kwargs)
        raise StopIteration(response)

    def _convert(self, ast):
        ClauseCollector(ast, self.log).visit()
        return self._cqlComposer.compose(ast)
示例#3
0
class Cql2SolrLuceneQuery(Observable, Logger):
    def __init__(self, unqualifiedFields, name=None):
        Observable.__init__(self, name=name)
        self._cqlComposer = SolrLuceneQueryComposer(unqualifiedFields)

    def executeQuery(self, cqlAbstractSyntaxTree, *args, **kwargs):
        filterQueries = kwargs.get('filterQueries', [])
        filterQueries = [self._convert(fq) for fq in filterQueries]
        response = yield self.any.executeQuery(
            luceneQueryString=self._convert(cqlAbstractSyntaxTree),
            *args,
            **kwargs)
        raise StopIteration(response)

    def _convert(self, ast):
        ClauseCollector(ast, self.log).visit()
        return self._cqlComposer.compose(ast)