コード例 #1
0
    def _Count(self, node):

        if node.getType() != ExpressionParser.NAME:
            raise _ExpressionError(
                'The argument to count() must be a simple field name')
        if self._is_sort_expression:
            raise query_parser.QueryException(
                'Failed to parse sort expression \'count(' + node.getText() +
                ')\': count() is not supported in sort expressions')
        return search_util.GetFieldCountInDocument(
            self._doc_pb, query_parser.GetQueryNodeText(node))
コード例 #2
0
def ValidateQuery(query):
  parser_return = query_parser.Parse(six.text_type(query, 'utf-8'))
  if parser_return.tree and parser_return.tree.getType() is QueryParser.EMPTY:
    raise query_parser.QueryException('Empty query.')