Need a special offer?Find out if your project fits.
+

Elasticsearch _search query with filter bug

Answered
test0test0test asked on October 8, 2020

The elasticsearch _search produces different queries on multiple instances even though the same filters are being selected.
For example,
Filter

  1. Apple
  2. Orange  <selected>
  3. Pear      <selected>

When the search is fired to elasticsearch, these are the two variations that appear on multiple instances

1. query: bool : must : [] must_not: bool:  should: term : Apple

2. query: bool : must : bool:  should: term : Orange term: Pear must_not: []
This two different queries return very different results, given that my records contain attributes that are arrays.

Record 1               Fruits: [Apple, Orange, Pear]
Record 2               Fruits: []
Happened on v2.8.17 of flexmonster 

7 answers

Public
Milena Pechura Milena Pechura Flexmonster October 9, 2020

Hello!
 
Thank you for posting to our forum.
 
We would like to kindly explain that sending different filter queries is expected behavior. Depending on the user actions (select or deselect) the corresponding must or must_not clause will appear in the query.
 
However, receiving different results is not expected.
Could you please provide us with the sample Elasticsearch index that returns different results for the same filter? Your report and steps to reproduce the issue would also greatly help us in our investigation.
 
Looking forward to your response.
 
Best regards,
Milena

Public
test0test0test October 12, 2020

Hello,
Elasticsearch:  v7.9.2
Flexmonster: v2.8.17

Sample data:
{"index": {"_type":"index1"}}
{"id" : "1", "fruits": ["Apple", "Orange", "Pear"]}
{"index": {"_type":"index1"}}
{"id" : "2", "fruits": ["Apple", "Orange", "Pear"]}
{"index": {"_type":"index1"}}
{"id" : "3", "fruits": ["Apple", "Orange", "Pear"]}
 
Load the dataset, click on the filter, uncheck Apple, search.
query: bool : must : [] must_not: bool:  should: term : Apple
Click on the filter, uncheck Orange, check Apple and Pear, search.
Click on the filter again, uncheck Apple, check Orange and Pear, search.

query: bool : must : bool:  should: term : Orange term: Pear must_not: []

Public
Milena Pechura Milena Pechura Flexmonster October 13, 2020

Hello,
 
Thank you for providing further info about the component behavior.
 
Our team is going to research the issue and provide you with results ETA Nov 16.
 
Please let us know if it works for you and if any other questions arise.
 
Best regards,
Milena

Public
test0test0test October 22, 2020

Yup will be waiting for your reply
 
Thank you!

Public
Milena Pechura Milena Pechura Flexmonster November 17, 2020

Hello,
 
Thank you for giving us some time.
Here, we would like to share the results of the research.
 
Our team has managed to reproduce the described behavior on our side. The filter performs the same as you described in your previous messages. It is only reproducible when the field has multiple values in Elasticsearch.
 
As far as we know, Elasticsearch does not have a separate data type for the arrays. Therefore, it is not possible to define whether the field has multiple values based on the mapping response. 
Please note that currently, Flexmonster does not support array data type. Our filtering implementation works correctly for single value data and does not expect multiple values case.
 
With that in mind, could you please specify how critical is such functionality for you to have? We recommend you contacting your customer service manager to discuss the possible solutions for your case.
 
Please let us know in case any other questions arise.
 
Kind regards,
Milena

Public
Milena Pechura Milena Pechura Flexmonster December 1, 2020

Hi!
 
How are you?
 
Our team would like to kindly take an interest in whether you had a chance to check out the results of the research.
Did it help to find a solution for your case?
 
Waiting for your reply.
 
Best regards,
Milena

Public
Milena Pechura Milena Pechura Flexmonster December 8, 2020

Hello,
 
Hope you are doing well!
 
We were wondering whether you had a chance to check our response.
Did the results of our research help?
 
Our team would be glad to hear your feedback.
 
Kind regards,
Milena

Please login or Register to Submit Answer