弹性搜索查询字符串的解析器

Parser for Elastic Search query strings

我想知道是否有可用的语法来解析发送到 Elastic Search 的查询字符串 query_string API

参考在这里:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax

我更喜欢 EBNF。我目前使用 Python 以防万一。

您可以在此处找到 Lucene 查询字符串查询解析器的 EBNF 语法: https://github.com/apache/lucene-solr/blob/master/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.jj

相关的构建步骤在这里: https://github.com/apache/lucene-solr/blob/1d85cd783863f75cea133fb9c452302214165a4d/lucene/queryparser/build.xml#L63-L79

嗖嗖 (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)