How to use the pandasticsearch.filters.Filter function in pandasticsearch

To help you get started, we’ve selected a few pandasticsearch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github onesuper / pandasticsearch / pandasticsearch / filters.py View on Github external
self._filter = {'range': {dim: {'gte': value}}}


class Greater(Filter):
    def __init__(self, dim, value):
        super(Greater, self).__init__()
        self._filter = {'range': {dim: {'gt': value}}}


class LessEqual(Filter):
    def __init__(self, dim, value):
        super(LessEqual, self).__init__()
        self._filter = {'range': {dim: {'lte': value}}}


class Less(Filter):
    def __init__(self, dim, value):
        super(Less, self).__init__()
        self._filter = {'range': {dim: {'lt': value}}}


class Equal(Filter):
    def __init__(self, dim, value):
        super(Equal, self).__init__()
        self._filter = {'term': {dim: value}}


class IsIn(Filter):
    def __init__(self, dim, value):
        super(IsIn, self).__init__()
        assert isinstance(value, list)
        self._filter = {'terms': {dim: value}}
github onesuper / pandasticsearch / pandasticsearch / filters.py View on Github external
def build(self):
        return self._filter

    def debug_string(self, indent=4):
        return json.dumps(self._filter, indent=indent)


# Binary operator
class And(Filter):
    def __init__(self, *args):
        [isinstance(x, Filter) for x in args]
        super(And, self).__init__()
        self._filter = {'bool': {'must': [x.build() for x in args]}}


class Or(Filter):
    def __init__(self, *args):
        [isinstance(x, Filter) for x in args]
        super(Or, self).__init__()
        self._filter = {'bool': {'should': [x.build() for x in args]}}


class Not(Filter):
    def __init__(self, x):
        assert isinstance(x, Filter)
        super(Not, self).__init__()
        self._filter = {'bool': {'must_not': x.build()}}


# Leaves
class GreaterEqual(Filter):
    def __init__(self, dim, value):
github onesuper / pandasticsearch / pandasticsearch / filters.py View on Github external
class Or(Filter):
    def __init__(self, *args):
        [isinstance(x, Filter) for x in args]
        super(Or, self).__init__()
        self._filter = {'bool': {'should': [x.build() for x in args]}}


class Not(Filter):
    def __init__(self, x):
        assert isinstance(x, Filter)
        super(Not, self).__init__()
        self._filter = {'bool': {'must_not': x.build()}}


# Leaves
class GreaterEqual(Filter):
    def __init__(self, dim, value):
        super(GreaterEqual, self).__init__()
        self._filter = {'range': {dim: {'gte': value}}}


class Greater(Filter):
    def __init__(self, dim, value):
        super(Greater, self).__init__()
        self._filter = {'range': {dim: {'gt': value}}}


class LessEqual(Filter):
    def __init__(self, dim, value):
        super(LessEqual, self).__init__()
        self._filter = {'range': {dim: {'lte': value}}}
github onesuper / pandasticsearch / pandasticsearch / filters.py View on Github external
def __init__(self, *args):
        [isinstance(x, Filter) for x in args]
        super(Or, self).__init__()
        self._filter = {'bool': {'should': [x.build() for x in args]}}
github onesuper / pandasticsearch / pandasticsearch / filters.py View on Github external
    @property
    def subtree(self):
        if 'bool' in self._filter:
            return self._filter['bool']
        else:
            return self._filter

    def build(self):
        return self._filter

    def debug_string(self, indent=4):
        return json.dumps(self._filter, indent=indent)


# Binary operator
class And(Filter):
    def __init__(self, *args):
        [isinstance(x, Filter) for x in args]
        super(And, self).__init__()
        self._filter = {'bool': {'must': [x.build() for x in args]}}


class Or(Filter):
    def __init__(self, *args):
        [isinstance(x, Filter) for x in args]
        super(Or, self).__init__()
        self._filter = {'bool': {'should': [x.build() for x in args]}}


class Not(Filter):
    def __init__(self, x):
        assert isinstance(x, Filter)
github onesuper / pandasticsearch / pandasticsearch / filters.py View on Github external
class Not(Filter):
    def __init__(self, x):
        assert isinstance(x, Filter)
        super(Not, self).__init__()
        self._filter = {'bool': {'must_not': x.build()}}


# Leaves
class GreaterEqual(Filter):
    def __init__(self, dim, value):
        super(GreaterEqual, self).__init__()
        self._filter = {'range': {dim: {'gte': value}}}


class Greater(Filter):
    def __init__(self, dim, value):
        super(Greater, self).__init__()
        self._filter = {'range': {dim: {'gt': value}}}


class LessEqual(Filter):
    def __init__(self, dim, value):
        super(LessEqual, self).__init__()
        self._filter = {'range': {dim: {'lte': value}}}


class Less(Filter):
    def __init__(self, dim, value):
        super(Less, self).__init__()
        self._filter = {'range': {dim: {'lt': value}}}
github onesuper / pandasticsearch / pandasticsearch / filters.py View on Github external
self._filter = {'range': {dim: {'lte': value}}}


class Less(Filter):
    def __init__(self, dim, value):
        super(Less, self).__init__()
        self._filter = {'range': {dim: {'lt': value}}}


class Equal(Filter):
    def __init__(self, dim, value):
        super(Equal, self).__init__()
        self._filter = {'term': {dim: value}}


class IsIn(Filter):
    def __init__(self, dim, value):
        super(IsIn, self).__init__()
        assert isinstance(value, list)
        self._filter = {'terms': {dim: value}}
github onesuper / pandasticsearch / pandasticsearch / api.py View on Github external
def _build_query(self, aggs=None, filter=None, size=None):
        query = {}

        if aggs is not None and len(aggs) > 0:
            agg_dict = {}
            for agg in aggs:
                assert isinstance(agg, Aggregator)
                agg_dict.update(agg.build())
            query['aggregations'] = agg_dict

        if filter is not None:
            assert isinstance(filter, Filter)
            query['query'] = {'filtered': {'filter': filter.build()}}
        else:
            query['query'] = {"match_all": {}}

        if size is not None:
            query['size'] = size

        self._last_query = query
        return query
github onesuper / pandasticsearch / pandasticsearch / filters.py View on Github external
self._filter = {'range': {dim: {'gt': value}}}


class LessEqual(Filter):
    def __init__(self, dim, value):
        super(LessEqual, self).__init__()
        self._filter = {'range': {dim: {'lte': value}}}


class Less(Filter):
    def __init__(self, dim, value):
        super(Less, self).__init__()
        self._filter = {'range': {dim: {'lt': value}}}


class Equal(Filter):
    def __init__(self, dim, value):
        super(Equal, self).__init__()
        self._filter = {'term': {dim: value}}


class IsIn(Filter):
    def __init__(self, dim, value):
        super(IsIn, self).__init__()
        assert isinstance(value, list)
        self._filter = {'terms': {dim: value}}
github onesuper / pandasticsearch / pandasticsearch / filters.py View on Github external
# Binary operator
class And(Filter):
    def __init__(self, *args):
        [isinstance(x, Filter) for x in args]
        super(And, self).__init__()
        self._filter = {'bool': {'must': [x.build() for x in args]}}


class Or(Filter):
    def __init__(self, *args):
        [isinstance(x, Filter) for x in args]
        super(Or, self).__init__()
        self._filter = {'bool': {'should': [x.build() for x in args]}}


class Not(Filter):
    def __init__(self, x):
        assert isinstance(x, Filter)
        super(Not, self).__init__()
        self._filter = {'bool': {'must_not': x.build()}}


# Leaves
class GreaterEqual(Filter):
    def __init__(self, dim, value):
        super(GreaterEqual, self).__init__()
        self._filter = {'range': {dim: {'gte': value}}}


class Greater(Filter):
    def __init__(self, dim, value):
        super(Greater, self).__init__()