jurismarches / luqum

A lucene query parser generating ElasticSearch queries and more !
Other
187 stars 42 forks source link

Not able to parse certain lucene queries properly #67

Closed kpanchal-crest closed 3 years ago

kpanchal-crest commented 3 years ago

@jurismarches,

We have a Lucene query with the syntax like below: (state: "Completed" OR "Cancelled") AND (segment: "total" OR "cancelled") AND NOT (comment:"This is a sample")

The above Lucene query expects the events having values for:

  1. "state" field as "Completed" or "Cancelled",
  2. "segment" field "total" OR "cancelled"
  3. Comment not equal to "This is a sample"

However, the DSL query formed using the luqum module for the above lucene query is as follows: {'query': {'bool': {'must': [{'bool': {'should': [{'match_phrase': {'state': {'query': 'Completed'}}}, {'match_phrase': {'text': {'query': 'Cancelled'}}}]}}, {'bool': {'should': [{'match_phrase': {'segment': {'query': 'total'}}}, {'match_phrase': {'text': {'query': 'cancelled'}}}]}}, {'bool': {'must_not': [{'match_phrase': {'comment': {'query': 'This is a sample'}}}]}}]}}}

It can be seen in the above DSL that the 'state' field is now just expecting 'Completed'. 'Canceled' value is not getting expected from the 'text' field which is not in our environment. Similar behavior is seen in the 'segment' field parsing as well.

Can you help us on priority to resolve this issue so that we can continue leveraging luqum module in our application?

alexgarel commented 3 years ago

To my point of view, you misandurstand Lucene Query Language.

You should write:

state:("Completed" OR "Cancelled") AND segment:("total" OR "cancelled") AND NOT comment:"This is a sample"