Search code examples
pythonparsingelasticsearchgrammarebnf

Parser for Elastic Search query strings


I wonder if there is a grammar available which will be able to parse the query strings that are sent to Elastic Search query_string API?

The reference is here: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax

I'd prefer EBNF. I use Python currently just in case.


Solution

  • Whoosh (https://whoosh.readthedocs.io/en/latest/index.html) is a pure-Python search with a Lucene query parser you could repurpose to your own app. I think it leveraged the Lucene parser example in pyparsing (https://github.com/pyparsing/pyparsing/blob/master/examples/lucene_grammar.py)