jurismarches / luqum

A lucene query parser generating ElasticSearch queries and more !
Other
188 stars 40 forks source link

Unknown operation when parsing inequality field groups #56

Open borissnd opened 4 years ago

borissnd commented 4 years ago

Luqum parser yields UnknownOperation when parsing inequality with a FieldGroup.

Equality with FieldGroup:

>>> a = "a:(1 OR 2)"
>>> tree = parser.parse(a)
>>> print(repr(tree))
SearchField('a', FieldGroup(OrOperation(Word('1'), Word('2'))))

Inequality with FieldGroup:

>>> a = "a:>(1 OR 2)"
>>> tree = parser.parse(a)
>>> print(repr(tree))
UnknownOperation(SearchField('a', Word('>')), Group(OrOperation(Word('1'), Word('2'))))

Expected result:

SearchField('a', FieldGroup(OrOperation(Word('>1'), Word('>2'))))
alexgarel commented 4 years ago

Hello @borissnd

You're right it's not supported right now. We would have to change the lexer and the grammar to support it.

Feel free to propose to make a PR with test coverage.

Sorry for, on my side I wan't be able to work on this before at least one month.