Filter of type: (A AND B) OR (C AND D)

Hi,

How would I go about performing a filter of the form (A AND B) OR (C AND D)?
I understand that such filters are not supported but is there any way to perform such a query through other means?

Thanks

Hi @tanpinquan,

Indeed, you are right, we do not support filters in the form of (A AND B) OR (C AND D) because this logic is extremely costly for the engine and the resulting performance would be bad.

The best workaround is to perform two different queries, and then merge the results in your front-end:

index.search('your query', { filters: 'A AND B' }) 
-- AND --
index.search('your query', { filters: 'C AND D' }) 

This is not a great option but it allows you to get exactly these results.

We have also found out that the need for this specific logic is actually quite rare (although it can happen!) in real business use cases. Could you share more about your use case so that we can maybe think of another way to formulate the query?

Thanks in advance!

Hey @marie.gillier, Thanks for replying. Actually I am also facing the same challenge where I have need to use OR operator, though I used multiquery approach and that help me out to solve OR operator logic problem.

Now, I am have multiple results that I have merged and show up on UI, With this I have challenge to maintaining paging and filtering .do you have solution for this ?

Thanks