SyliusElasticsearchPlugin icon indicating copy to clipboard operation
SyliusElasticsearchPlugin copied to clipboard

Attribute with boolean value is incorrectly queried as .keyword

Open olia-bn opened this issue 5 years ago • 1 comments

I have a bunch of attributes in my project that are checkboxes (have boolean value) and trying to filter by them returns no results.

After debugging the problem I've noticed that the elastic query uses .keyword, but that is not correct for boolean fields as far as I know (it is correct for the string-values attributes)

In terms of elastic queries: this plugin uses the following:

      "should": [
        {
          "term": {
            "attribute_e89.keyword": {
              "value": "1"
            }
          }
        }
      ]

but this does not work. It should be doing the following (for boolean values):

      "should": [
        {
          "term": {
            "attribute_e89": {
              "value": true
            }
          }
        }
      ]

This is because the boolean attribute translates to boolean value in elastica:

      {
        "_index" : "shop_products_dev",
        "_type" : "default",
        "_id" : "2630",
        "_score" : 0.031748697,
        "_source" : {
          "enabled" : true,
          "name_nl_nl" : "Lightning-USB Adapter voor iPhone",
          "attribute_e84" : [
            true
          ],
          "attribute_e89" : [
            true
          ],
         ...

olia-bn avatar Dec 04 '20 13:12 olia-bn

Hi, this issue is on same place of code https://github.com/BitBagCommerce/SyliusElasticsearchPlugin/issues/35

stargen avatar Jan 12 '21 15:01 stargen

Looks like issue was fixed already, print screen with boolean attribute and correct search result below. image

rafalmal avatar Apr 07 '23 10:04 rafalmal