Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter boolean seem to be not working on virtual category #2434

Closed
walkwizus opened this issue Jan 27, 2022 · 8 comments
Closed

Filter boolean seem to be not working on virtual category #2434

walkwizus opened this issue Jan 27, 2022 · 8 comments
Assignees
Labels

Comments

@walkwizus
Copy link

walkwizus commented Jan 27, 2022

Hi,

On a virtual category, filter with boolean value seem to be not working when value is false.

Magento Version : CE

ElasticSuite Version : 2.10.9

Environment : Development

Steps to reproduce

  1. Add a boolean attribute (Yes/No)
  2. Create a virtual category
  3. Add a filter with the boolean attribute having the value "No"

Expected result

  1. Boolean filter was applied when value is false.

Actual result

  1. Filter appear in the ES request when his value is true
  2. Filter doesn't appear in the ES request when his value is false

Thanks !

@vahonc
Copy link
Collaborator

vahonc commented Jan 28, 2022

Hello @walkwizus

Could you provide us more details (screenshots) about configuring your virtual category (condition for rule) and your boolean attribute?

BR,
Vadym

@walkwizus
Copy link
Author

Hello @vahonc,

I've installed a Vanilla version of Magento CE 2.4.3-p1.

I've added a boolean attribute. You can see how is configured the boolean attribute on the following screenshots:

attributes_properties

advance_attribute_properties

storefront_properties

search_configuration

I've created two products, one with bool attribute set to false and another with bool attribute set to true. You can see my products on the following screenshots:

product_test_bool_true

product_test_bool_false

So at this point, I've created a virtual category with a condition on my bool attribute. As you can see, if I choose "yes" value, there are only one product on the product list preview. If I choose the "no" value, there are two products on the product list preview.

virtual_category_yes

virtual_category_no

Here you can see all request in system.log file.

Request when bool attribute is set to "Yes":

[2022-02-01 06:29:54] main.INFO: Request Success: {"method":"HEAD","uri":"http://elasticsearch/magento2_default_catalog_product","port":9200,"headers":{"Host":["elasticsearch"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.11.0 (Linux 5.10.76-linuxkit; PHP 7.4.26)"],"x-elastic-client-meta":["es=7.11.0,php=7.4.26,t=7.11.0,a=0,cu=7.64.0"]},"HTTP code":200,"duration":0.009222} []
[2022-02-01 06:29:54] main.INFO: curl -XHEAD 'http://elasticsearch/magento2_default_catalog_product?pretty=true' [] []
[2022-02-01 06:29:55] main.INFO: Request Success: {"method":"GET","uri":"http://elasticsearch/","port":9200,"headers":{"Host":["elasticsearch"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.11.0 (Linux 5.10.76-linuxkit; PHP 7.4.26)"],"x-elastic-client-meta":["es=7.11.0,php=7.4.26,t=7.11.0,a=0,cu=7.64.0"]},"HTTP code":200,"duration":0.001594} []
[2022-02-01 06:29:55] main.INFO: curl -XGET 'http://elasticsearch/?pretty=true' [] []
[2022-02-01 06:29:55] main.INFO: Request Success: {"method":"POST","uri":"http://elasticsearch/magento2_default_catalog_product/_search","port":9200,"headers":{"Host":["elasticsearch"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.11.0 (Linux 5.10.76-linuxkit; PHP 7.4.26)"],"x-elastic-client-meta":["es=7.11.0,php=7.4.26,t=7.11.0,a=0,cu=7.64.0"]},"HTTP code":200,"duration":0.009165} []
[2022-02-01 06:29:55] main.INFO: curl -XPOST 'http://elasticsearch/magento2_default_catalog_product/_search?pretty=true' -d '{"size":0,"query":{"constant_score":{"filter":{"bool":{"must":[{"bool":{"must":[{"terms":{"variation_end_of_sales":[true],"boost":1}}],"must_not":[],"should":[],"boost":1}},{"term":{"stock.is_in_stock":{"value":true,"boost":1}}},{"terms":{"visibility":[2,4],"boost":1}},{"terms":{"visibility":[2,4],"boost":1}}],"must_not":[],"should":[],"boost":1}},"boost":1}},"aggregations":{"attribute_set_id":{"terms":{"field":"attribute_set_id","size":100000,"order":{"_count":"desc"}}},"indexed_attributes":{"terms":{"field":"indexed_attributes","size":100000,"order":{"_count":"desc"}}},"price.price":{"nested":{"path":"price"},"aggregations":{"price.price":{"filter":{"terms":{"price.customer_group_id":[0],"boost":1}},"aggregations":{"price.price":{"histogram":{"field":"price.price","interval":1,"min_doc_count":1}}}}}},"option_text_manufacturer":{"terms":{"field":"option_text_manufacturer.untouched","size":10,"order":{"_count":"desc"}}},"option_text_color":{"terms":{"field":"option_text_color.untouched","size":10,"order":{"_count":"desc"}}},"variation_end_of_sales":{"terms":{"field":"variation_end_of_sales","size":10,"order":{"_count":"desc"}}}},"track_total_hits":true}' [] []
[2022-02-01 06:29:55] main.INFO: Request Success: {"method":"POST","uri":"http://elasticsearch/magento2_default_catalog_product/_search","port":9200,"headers":{"Host":["elasticsearch"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.11.0 (Linux 5.10.76-linuxkit; PHP 7.4.26)"],"x-elastic-client-meta":["es=7.11.0,php=7.4.26,t=7.11.0,a=0,cu=7.64.0"]},"HTTP code":200,"duration":0.013785} []
[2022-02-01 06:29:55] main.INFO: curl -XPOST 'http://elasticsearch/magento2_default_catalog_product/_search?pretty=true' -d '{"size":20,"sort":[{"_score":{"order":"desc"}},{"entity_id":{"order":"desc","missing":"_first","unmapped_type":"keyword"}}],"from":0,"query":{"constant_score":{"filter":{"bool":{"must":[{"bool":{"must":[{"terms":{"variation_end_of_sales":[true],"boost":1}}],"must_not":[],"should":[],"boost":1}},{"term":{"stock.is_in_stock":{"value":true,"boost":1}}},{"terms":{"visibility":[2,4],"boost":1}},{"terms":{"visibility":[2,4],"boost":1}}],"must_not":[],"should":[],"boost":1}},"boost":1}},"aggregations":{"attribute_set_id":{"terms":{"field":"attribute_set_id","size":100000,"order":{"_count":"desc"}}},"price.price":{"nested":{"path":"price"},"aggregations":{"price.price":{"filter":{"terms":{"price.customer_group_id":[0],"boost":1}},"aggregations":{"price.price":{"histogram":{"field":"price.price","interval":1,"min_doc_count":1}}}}}},"option_text_manufacturer":{"terms":{"field":"option_text_manufacturer.untouched","size":10,"order":{"_count":"desc"}}},"option_text_color":{"terms":{"field":"option_text_color.untouched","size":10,"order":{"_count":"desc"}}},"variation_end_of_sales":{"terms":{"field":"variation_end_of_sales","size":10,"order":{"_count":"desc"}}}},"track_total_hits":true}' [] []

Request when bool attribute is set to "No":

[2022-02-01 06:31:18] main.INFO: Request Success: {"method":"HEAD","uri":"http://elasticsearch/magento2_default_catalog_product","port":9200,"headers":{"Host":["elasticsearch"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.11.0 (Linux 5.10.76-linuxkit; PHP 7.4.26)"],"x-elastic-client-meta":["es=7.11.0,php=7.4.26,t=7.11.0,a=0,cu=7.64.0"]},"HTTP code":200,"duration":0.024892} []
[2022-02-01 06:31:18] main.INFO: curl -XHEAD 'http://elasticsearch/magento2_default_catalog_product?pretty=true' [] []
[2022-02-01 06:31:18] main.INFO: Request Success: {"method":"GET","uri":"http://elasticsearch/","port":9200,"headers":{"Host":["elasticsearch"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.11.0 (Linux 5.10.76-linuxkit; PHP 7.4.26)"],"x-elastic-client-meta":["es=7.11.0,php=7.4.26,t=7.11.0,a=0,cu=7.64.0"]},"HTTP code":200,"duration":0.002931} []
[2022-02-01 06:31:18] main.INFO: curl -XGET 'http://elasticsearch/?pretty=true' [] []
[2022-02-01 06:31:18] main.INFO: Request Success: {"method":"POST","uri":"http://elasticsearch/magento2_default_catalog_product/_search","port":9200,"headers":{"Host":["elasticsearch"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.11.0 (Linux 5.10.76-linuxkit; PHP 7.4.26)"],"x-elastic-client-meta":["es=7.11.0,php=7.4.26,t=7.11.0,a=0,cu=7.64.0"]},"HTTP code":200,"duration":0.014606} []
[2022-02-01 06:31:18] main.INFO: curl -XPOST 'http://elasticsearch/magento2_default_catalog_product/_search?pretty=true' -d '{"size":0,"query":{"constant_score":{"filter":{"bool":{"must":[{"bool":{"must":[],"must_not":[],"should":[],"boost":1}},{"term":{"stock.is_in_stock":{"value":true,"boost":1}}},{"terms":{"visibility":[2,4],"boost":1}},{"terms":{"visibility":[2,4],"boost":1}}],"must_not":[],"should":[],"boost":1}},"boost":1}},"aggregations":{"attribute_set_id":{"terms":{"field":"attribute_set_id","size":100000,"order":{"_count":"desc"}}},"indexed_attributes":{"terms":{"field":"indexed_attributes","size":100000,"order":{"_count":"desc"}}},"price.price":{"nested":{"path":"price"},"aggregations":{"price.price":{"filter":{"terms":{"price.customer_group_id":[0],"boost":1}},"aggregations":{"price.price":{"histogram":{"field":"price.price","interval":1,"min_doc_count":1}}}}}},"option_text_manufacturer":{"terms":{"field":"option_text_manufacturer.untouched","size":10,"order":{"_count":"desc"}}},"option_text_color":{"terms":{"field":"option_text_color.untouched","size":10,"order":{"_count":"desc"}}},"variation_end_of_sales":{"terms":{"field":"variation_end_of_sales","size":10,"order":{"_count":"desc"}}}},"track_total_hits":true}' [] []
[2022-02-01 06:31:18] main.INFO: Request Success: {"method":"POST","uri":"http://elasticsearch/magento2_default_catalog_product/_search","port":9200,"headers":{"Host":["elasticsearch"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.11.0 (Linux 5.10.76-linuxkit; PHP 7.4.26)"],"x-elastic-client-meta":["es=7.11.0,php=7.4.26,t=7.11.0,a=0,cu=7.64.0"]},"HTTP code":200,"duration":0.012721} []
[2022-02-01 06:31:18] main.INFO: curl -XPOST 'http://elasticsearch/magento2_default_catalog_product/_search?pretty=true' -d '{"size":20,"sort":[{"_score":{"order":"desc"}},{"entity_id":{"order":"desc","missing":"_first","unmapped_type":"keyword"}}],"from":0,"query":{"constant_score":{"filter":{"bool":{"must":[{"bool":{"must":[],"must_not":[],"should":[],"boost":1}},{"term":{"stock.is_in_stock":{"value":true,"boost":1}}},{"terms":{"visibility":[2,4],"boost":1}},{"terms":{"visibility":[2,4],"boost":1}}],"must_not":[],"should":[],"boost":1}},"boost":1}},"aggregations":{"attribute_set_id":{"terms":{"field":"attribute_set_id","size":100000,"order":{"_count":"desc"}}},"price.price":{"nested":{"path":"price"},"aggregations":{"price.price":{"filter":{"terms":{"price.customer_group_id":[0],"boost":1}},"aggregations":{"price.price":{"histogram":{"field":"price.price","interval":1,"min_doc_count":1}}}}}},"option_text_manufacturer":{"terms":{"field":"option_text_manufacturer.untouched","size":10,"order":{"_count":"desc"}}},"option_text_color":{"terms":{"field":"option_text_color.untouched","size":10,"order":{"_count":"desc"}}},"variation_end_of_sales":{"terms":{"field":"variation_end_of_sales","size":10,"order":{"_count":"desc"}}}},"track_total_hits":true}' [] []

On the first request there are the bool attribute with correct value:

request_true

On the second request there are not the bool attribute:

request_false

I can provide an hosted instance if necessary.

Thanks

@romainruaud
Copy link
Collaborator

Check if PR #1305 can have some effect for this one.

@walkwizus
Copy link
Author

@romainruaud Unfortunately doesn't work in my case. This PR break all virtual categories rules.

@romainruaud
Copy link
Collaborator

Yes, this PR filters out a lot of things during indexation, I think that's a good path to explore but it definitely needs to be reworked.

Regards

@walkwizus
Copy link
Author

Don't know if there an issue with the indexing process or an issue with the both, indexing process and categories rules. When I'm requesting with postman directly all work fine with true or false value so I assume all bool values are indexed properly. I've this issue only when I try to add a boolean attribute on my category rule. So I will try to change my attribute with a dropdown to have a rapid fix.

thanks for your support !

@romainruaud romainruaud assigned rbayet and unassigned vahonc Feb 28, 2022
rbayet added a commit to rbayet/elasticsuite that referenced this issue Mar 15, 2022
rbayet added a commit to rbayet/elasticsuite that referenced this issue Mar 15, 2022
rbayet added a commit to rbayet/elasticsuite that referenced this issue Mar 15, 2022
@rbayet
Copy link
Collaborator

rbayet commented Mar 15, 2022

Hello @walkwizus,

Thanks for pointing the issue.
There was indeed a problem located in the search engine rule handling for 0/false condition values, this will be fixed by #2486

BUT you will also need the 2.10.x version of #2482 to effectively have false/No values of Boolean attributes to be indexed (this was not the case by default).
Please see my comment describing the option you will have to switch per-attribute when those fixes are available in the next release.

Regards,

rbayet added a commit to rbayet/elasticsuite that referenced this issue Mar 15, 2022
rbayet added a commit that referenced this issue Mar 15, 2022
Fixes #2434 Support false/zero value in catalog rules
rbayet added a commit that referenced this issue Mar 15, 2022
…ero_2.8.x

Fixes #2434 Support false/zero value in catalog rules (2.8.x)
@rbayet rbayet closed this as completed Mar 15, 2022
@walkwizus
Copy link
Author

Hi !

@rbayet Thanks for fixed this issue. I can't patch it easily because the 2.10.X branch differ from 2.10.9.1 release. When the next released is planned ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants