Smile-SA / elasticsuite

Smile ElasticSuite - Magento 2 merchandising and search engine built on ElasticSearch
https://elasticsuite.io
Open Software License 3.0
761 stars 341 forks source link

Filter configurable products wrong result #902

Closed Nix-id closed 6 years ago

Nix-id commented 6 years ago

Incorrect search result in LN

Magento Version : 2.2.2

ElasticSuite Version :

Environment : ^2.5

Third party modules : none

Steps to reproduce

  1. Create config product with attributes att1, att2, att3
  2. Remove child product with att3 value "att3_2" image
  3. search on frontend image in this product "att1" don't exist configuration for attribute value "att3_2" image

Expected result

  1. don't display in search result this product
Nix-id commented 6 years ago

Standart magento with mysql filter product correctly

image

Nix-id commented 6 years ago

i reindex all indexes and make cahce:clean cache:flush

afoucret commented 6 years ago

@romainruaud : can you have a look at this one ?

romainruaud commented 6 years ago

Hmm....

I just spent a lot of time on your issue and initially thought I was reproducing it.

TL; DR Version : The search engine is not proceeding an exact match of the tuple on children products, but is computing a match on parent product data which is a combination of existing children values.

Detailed version :

In fact, after removing one variation, there is still one which is existing with att_3 : att3_2. And it's even visible in your screenshot, with the id 168.

When you create a configurable product based on 3 attributes each one having 3 values, you obtain 27 variations :

+------------+------+------+------+
| product_id | att1 | att2 | att3 |
+------------+------+------+------+
|       2265 | A    | AA   | AAA  |
|       2266 | A    | AA   | BBB  |
|       2267 | A    | AA   | CCC  |
|       2268 | A    | BB   | AAA  |
|       2269 | A    | BB   | BBB  |
|       2270 | A    | BB   | CCC  |
|       2271 | A    | CC   | AAA  |
|       2272 | A    | CC   | BBB  |
|       2273 | A    | CC   | CCC  |
|       2274 | C    | AA   | AAA  |
|       2275 | C    | AA   | BBB  |
|       2276 | C    | AA   | CCC  |
|       2277 | C    | BB   | AAA  |
|       2278 | C    | BB   | BBB  |
|       2279 | C    | BB   | CCC  |
|       2280 | C    | CC   | AAA  |
|       2281 | C    | CC   | BBB  |
|       2282 | C    | CC   | CCC  |
|       2283 | B    | AA   | AAA  |
|       2284 | B    | AA   | BBB  |
|       2285 | B    | AA   | CCC  |
|       2286 | B    | BB   | AAA  |
|       2287 | B    | BB   | BBB  |
|       2288 | B    | BB   | CCC  |
|       2289 | B    | CC   | AAA  |
|       2290 | B    | CC   | BBB  |
|       2291 | B    | CC   | CCC  |
+------------+------+------+------+

Let's say you delete a children, the 2290 : you will delete the B/CC/BBB tuple.

But many tuples will remain having att3=BBB.

And since we only do index parent products, based on their children data, the parent product will still have BBB value for att3 since it still has children with this value.

That being said, when you are filtering on :

You are refering to an unexisting tuple. That's right, and I agree that no child product matching exactly this tuple does exist.

But the parent product does match these search criterias, because it has several childrens with att1=B, att2=CC and att3=BBB.

To understand better, here is what is indexed for the parent data in the search index, even after deleting the child product :

          "option_text_att1": [
            "A",
            "C",
            "B"
          ],
          "option_text_att2": [
            "AA",
            "BB",
            "CC"
          ],
          "option_text_att3": [
            "AAA",
            "BBB",
            "CCC"
          ],

This is a combination of all existing children values.

That's why the parent product is found when applying these filters.

=> The search engine is not proceeding an exact match of the tuple on children products, but is computing a match on parent product data which is a combination of existing children values.

So imho, there is nothing incorrect here, and we are working as expected.

Best regards, I close the issue since this is not a behavior we plan to change.

Nix-id commented 6 years ago

@romainruaud @afoucret

So imho, there is nothing incorrect here, and we are working as expected.

Without Elasticsuite (with mysql search) it is work different. By default, magento filters the product correctly and does not display this configuration product.