lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roman Chyla (JIRA)" <>
Subject [jira] [Updated] (LUCENE-5014) ANTLR Lucene query parser
Date Thu, 23 May 2013 00:27:21 GMT


Roman Chyla updated LUCENE-5014:

    Attachment: LUCENE-5014.txt

Patch without binary files (if possible, use the other patch)
> ANTLR Lucene query parser
> -------------------------
>                 Key: LUCENE-5014
>                 URL:
>             Project: Lucene - Core
>          Issue Type: Improvement
>          Components: core/queryparser, modules/queryparser
>    Affects Versions: 4.3
>         Environment: all
>            Reporter: Roman Chyla
>              Labels: antlr, query, queryparser
>         Attachments: LUCENE-5014.txt
> I would like to propose a new way of building query parsers for Lucene.  Currently, most
Lucene parsers are hard to extend because they are either written in Java (ie. the SOLR query
parser, or edismax) or the parsing logic is 'married' with the query building logic (i.e.
the standard lucene parser, generated by JavaCC) - which makes any extension really hard.
> Few years back, Lucene got the contrib/modern query parser (later renamed to 'flexible'),
yet that parser didn't become a star (it must be very confusing for many users). However,
that parsing framework is very powerful! And it is a real pity that there aren't more parsers
already using it - because it allows us to add/extend/change almost any aspect of the query
> So, if we combine ANTLR + queryparser.flexible, we can get very powerful framework for
building almost any query language one can think of. And I hope this extension can become
> The details:
>  - every new query syntax is written in EBNF, it lives in separate files (and can be
tested/developed independently - using 'gunit')
>  - ANTLR parser generates parsing code (and it can generate parsers in several languages,
the main target is Java, but it can also do Python - which may be interesting for pylucene)
>  - the parser generates AST (abstract syntax tree) which is consumed by a  'pipeline'
of processors, users can easily modify this pipeline to add a desired functionality
>  - the new parser contains a few (very important) debugging functions; it can print results
of every stage of the build, generate AST's as graphical charts; ant targets help to build/test/debug
>  - I've tried to reuse the existing queryparser.flexible components as much as possible,
only adding new processors when necessary
> Assumptions about the grammar:
>  - every grammar must have one top parse rule called 'mainQ'
>  - parsers must generate AST (Abstract Syntax Tree)
> The structure of the AST is left open, there are components which make assumptions about
the shape of the AST (ie. that MODIFIER is parent of a a FIELD) however users are free to
choose/write different processors with different assumptions about the AST shape.
> More documentation on how to use the parser can be seen here:
> The parser has been created more than one year back and is used in production (
A different dialects of query languages (with proximity operatos, functions, special logic
etc) - can be seen here: 

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message