What is the correct way to parse a Lucene query in python?

I need to parse terms and operators from a lucene query in python.

The syntax is described here: http://lucene.apache.org/core/2_9_4/queryparsersyntax.html

For example, I would like to get terms and operators from such a query:

title:"The Right Way" AND text:go 

Are there existing modules with parsers for lucene queries in python?

I could write a parser using ply or pyparse, but I would like to know if it already exists or if there are alternative solutions.

+4
source share
1 answer

pyparsing offers lucene parser as examples. pyparsing is written in pure Python without external dependencies. This is apparently the most reliable implementation.

+5
source

Source: https://habr.com/ru/post/1500983/


All Articles