Package to parse Kibana Query Language (KQL) strings.
Project description
kibana-ql
Parser for the Kibana Query Language (KQL).
Install
pip install kibana-ql
Use
from kibana_ql import KqlParser
p = KqlParser()
tree = p.parse("field: value")
p.ast(tree) # {'field': 'field', 'value': 'value'}
tree = p.parse('document: "tax" and @date > now-2w')
p.ast(tree) # {'op': 'and', 'left': {'field': 'document', 'value': 'tax'}, 'right': {'field': '@date', 'op': '>', 'value': ('now-2w',)}}
Tests
py -m unittest discover -v -s tests -p "*_test.py"
Notes
Grammar file based on https://github.com/elastic/kibana/blob/main/packages/kbn-es-query/src/kuery/grammar/grammar.peggy.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
kibana_ql-0.2.tar.gz
(3.8 kB
view hashes)