https://github.com/russellluo/onefilter
One filter for all structured data.
https://github.com/russellluo/onefilter
Last synced: over 1 year ago
JSON representation
One filter for all structured data.
- Host: GitHub
- URL: https://github.com/russellluo/onefilter
- Owner: RussellLuo
- Created: 2017-01-02T02:16:55.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-10T14:08:55.000Z (over 9 years ago)
- Last Synced: 2025-02-16T04:17:05.703Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OneFilter
One filter for all structured data.
## Getting started
```pycon
>>> from onefilter import F, And, Or, Eq, In, Gte, Lte, Exists
>>> from onefilter.es import ES
>>> f = F(a=1, b=In(2, 3, 4), c=And(Gte(5), Lte(9)), d=Or(Exists(False), Eq(0)))
>>> c = ES(f)
>>> import pprint; pprint.pprint(c)
{'bool': {'must': [{'term': {'a': 1}},
{'range': {'c': {'gte': 5, 'lte': 9}}},
{'terms': {'b': [2, 3, 4]}},
{'bool': {'should': [{'must_not': {'exists': {'field': 'd'}}},
{'term': {'d': 0}}]}}]}}
```
## License
[MIT][3]
[3]: http://opensource.org/licenses/MIT