elasticsuite icon indicating copy to clipboard operation
elasticsuite copied to clipboard

RequestMapper::getFilters() does not support Logical OR

Open shochdoerfer opened this issue 6 years ago • 6 comments

I tried to send a bit more complex search query like this one from the dev docs combining Logical AND and OR:

searchCriteria[filter_groups][0][filters][0][field]=sku&
searchCriteria[filter_groups][0][filters][0][value]=WSH%2529%25&
searchCriteria[filter_groups][0][filters][0][condition_type]=like&
searchCriteria[filter_groups][0][filters][1][field]=sku&
searchCriteria[filter_groups][0][filters][1][value]=WP%2529%25&
searchCriteria[filter_groups][0][filters][1][condition_type]=like&
searchCriteria[filter_groups][1][filters][0][field]=price&
searchCriteria[filter_groups][1][filters][0][value]=40&
searchCriteria[filter_groups][1][filters][0][condition_type]=from&
searchCriteria[filter_groups][2][filters][0][field]=price&
searchCriteria[filter_groups][2][filters][0][value]=49.99&
searchCriteria[filter_groups][2][filters][0][condition_type]=to

As it looks to me, this does not work as the RequestMapper::getFilters() treats all filters and filter groups the same. Is this assumption right or am I missing something?

shochdoerfer avatar Aug 10 '18 08:08 shochdoerfer

Hello @shochdoerfer

seems you are right.

I think @afoucret should also have a look on this one.

regards

romainruaud avatar Aug 20 '18 14:08 romainruaud

Digging more on this one, it remains completely unclear for me how Magento can distinguish between several filter_groups to split them into logical OR when I read the code of the legacy search adapter :

https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/Search/Search.php#L63

It's more likely non-working either with legacy Magento search API entry point. Did you test it to confirm or infirm ?

The doc you link is speaking about the products entry point, which is using the product repository for searching (so Elasticsuite not involved here).

romainruaud avatar Aug 22 '18 09:08 romainruaud

Need to check again to be sure. If I am not mistaken, my colleague tested it with the products endpoint and it seemed to work as described.

shochdoerfer avatar Aug 22 '18 20:08 shochdoerfer

yep, that's what I'm saying :

  • Magento legacy products endpoint produce logical AND and OR as stated in the doc.
  • Magento legacy search endpoint does not.
  • We plug Elasticsuite only on search endpoint and thefore get inspired from what Magento was doing on this endpoint.

So far : Elasticsuite does have the same functional as Magento on search endpoint. But yes, I think we could maybe enhance this to achieve better.

romainruaud avatar Aug 23 '18 07:08 romainruaud

Hi, Do you have any update on this issue? Do you know if someone is working on it or if we can help to implement this feature?

lucasmilin avatar Jul 30 '20 00:07 lucasmilin

@lucasmilin I don't think we'll work on this ~~issue~~ feature because REST Api does not seem to be the preferred way to query Magento 2 API since Graphql's inception.

But I'd be happy reviewing any PR from your side on this implementation :)

Regards

romainruaud avatar Jul 30 '20 08:07 romainruaud