Skip to content

Conversation

@gibkigonzo
Copy link
Contributor

Short Description and Why It's Useful

Right now when we make search for attributes we build invalid query (createAttributesListQuery). 'is_user_defined' and 'is_visible' can also have '1' as value, not only true.

Which Environment This Relates To

Check your case. In case of any doubts please read about Release Cycle

  • Test version (https://test.storefrontcloud.io) - this is a new feature or improvement for Vue Storefront. I've created branch from develop branch and want to merge it back to develop
  • RC version (https://next.storefrontcloud.io) - this is a stabilisation fix for Release Candidate of Vue Storefront. I've created branch from release branch and want to merge it back to release
  • Stable version (https://demo.storefrontcloud.io) - this is an important fix for current stable version. I've created branch from hotfix or master branch and want to merge it back to hotfix

Upgrade Notes and Changelog

  • No upgrade steps required (100% backward compatibility and no breaking changes)
  • I've updated the Upgrade notes and Changelog on how to port existing Vue Storefront sites with this new feature

IMPORTANT NOTICE - Remember to update CHANGELOG.md with description of your change

Contribution and Currently Important Rules Acceptance

@andrzejewsky andrzejewsky merged commit e565b29 into vuestorefront:hotfix/v1.11.2 Feb 11, 2020
@flancer64
Copy link
Contributor

I have an error

{
  "type": "illegal_argument_exception",
  "reason": "Can't parse boolean value [1], expected [true] or [false]"
}

for query (Elasticsearch version: "7.6.1"):

{
  "bool": {
    "filter": [
      {
        "bool": {
          "must": [
            {
              "terms": {
                "attribute_code": ["..."],
                "boost": 1.0
              }
            },
            {
              "terms": {
                "is_user_defined": [true, "1"],
                "boost": 1.0
              }
            },
            {
              "terms": {
                "is_visible": [true, "1"],
                "boost": 1.0
              }
            }
          ],
          "adjust_pure_negative": true,
          "boost": 1.0
        }
      }
    ],
    "adjust_pure_negative": true,
    "boost": 1.0
  }
}

This is data types mapping for my index of attributes:

{
  "mappings": {
    "_doc": {
      "properties": {
        "frontend_label": {"type": "text", "fields": {"keyword": {"ignore_above": 256, "type": "keyword"}}},
        "is_visible": {"type": "boolean"},
        "is_visible_on_front": {"type": "boolean"},
        "attribute_id": {"type": "long"},
        "options": {
          "properties": {
            "label": {"type": "text", "fields": {"keyword": {"ignore_above": 256, "type": "keyword"}}},
            "value": {"type": "text"}
          }
        },
        "id": {"type": "long"},
        "frontend_input": {"type": "text", "fields": {"keyword": {"ignore_above": 256, "type": "keyword"}}},
        "is_user_defined": {"type": "boolean"},
        "attribute_code": {"type": "text", "fields": {"keyword": {"ignore_above": 256, "type": "keyword"}}},
        "is_comparable": {"type": "boolean"}
      }
    }
  }
}

I'm nub in Elasticsearch, probably there is some configuration option to ignore data types in queries but I don't know. Just share my case.

@flancer64
Copy link
Contributor

I see that Elasticsearch version 5.6 allows different values for boolean:

False values | false, "false", "off", "no", "0", "" (empty string), 0, 0.0
-- | --
True values | Anything that isn’t false.

but version 6.0 and above don't:

False values | false, "false"
-- | --
True values | true, "true"

I suppose we should revert these changes or make query more smart (add ES version dependency).

@mwalol
Copy link

mwalol commented Apr 12, 2020

hi,

i'm using elasticsearch 7.3 and i had to change :

  if (onlyDefinedByUser) {
    searchQuery = searchQuery.applyFilter({ key: 'is_user_defined', value: { 'in': [true] } })
  }
  if (onlyVisible) {
    searchQuery = searchQuery.applyFilter({ key: 'is_visible', value: { 'in': [true] } })
  }

instead of [true, '1'] to fix the issue a more generic solution would be welcome

@SDLyu
Copy link
Contributor

SDLyu commented Apr 23, 2020

Hi @gibkigonzo
This is not working in ElasticSearch 7.
I get error

{
  "type": "illegal_argument_exception",
  "reason": "Can't parse boolean value [1], expected [true] or [false]"
}

@gepdev
Copy link

gepdev commented Apr 29, 2020

Hi @gibkigonzo
This is not working in ElasticSearch 7.
I get error

{
  "type": "illegal_argument_exception",
  "reason": "Can't parse boolean value [1], expected [true] or [false]"
}

I have the same error with ES 7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants