Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query parsing in ANTLR for Lucene

Probably it will combine several questions, but the context is the same.

Background: I need to implement custom query parsing for Lucene. The reason is that i dont store some fields in Lucene, but just keep them in a separate db, because they are changing too often. This field is classification category, i.e. cat

So, I want to parse the query like this:

(cat:important and hello) or (cat:not_important and hi)

Are there any standard ANTLR4 query parsers (or examples) for Lucene like language? Is there a way to introduce custom QueryNode without need for me to rewrite everything (Sytax, QueryBuilders, and etc.) from scratch?

Thanks a lot folks!!!

like image 842
NeatNerd Avatar asked Nov 04 '22 05:11

NeatNerd


1 Answers

I would even:

  1. modify the original StandardQueryParser.jj file, generating another QueryParser with the help of JavaCC (which generates LL descent parsers just like AntLR),

  2. translate the original StandardQueryParser.jj file to the correct AntLR grammar syntax, or

  3. check if ExtendableQueryParser isn't enough for that kind of fields.

like image 75
Martín Schonaker Avatar answered Nov 14 '22 23:11

Martín Schonaker