elasticsearch.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:falcon-api 作者: Opentopic 项目源码 文件源码
def _parse_logical_op(self, arg, value, op, prevent_expand=True):
        if isinstance(value, dict):
            return self._build_filter_expressions(value, op, prevent_expand=prevent_expand)
        if not isinstance(value, list):
            raise HTTPBadRequest('Invalid attribute', 'Filter attribute {} is invalid'.format(arg))
        parts = []
        for subconditions in value:
            if not isinstance(subconditions, dict):
                raise HTTPBadRequest('Invalid attribute', 'Filter attribute {} is invalid'.format(arg))
            subexpressions = self._build_filter_expressions(subconditions, 'must', prevent_expand=prevent_expand)
            if subexpressions is not None:
                parts.append(subexpressions)
        result = None
        if len(parts) > 1:
            parts = self._group_nested(parts, op)
        if len(parts) > 1:
            result = {'bool': {op: parts}}
        elif len(parts) == 1:
            result = parts[0] if op != 'must_not' else {'bool': {'must_not': parts[0]}}
        return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号