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

Price filter does not filter the price on customer group #1096

Closed
nicobatty opened this issue Sep 26, 2018 · 3 comments
Closed

Price filter does not filter the price on customer group #1096

nicobatty opened this issue Sep 26, 2018 · 3 comments
Assignees
Labels

Comments

@nicobatty
Copy link

After I started debugging the ElasticSearch requests, I noticed that there were no filter on the customer group when filtering the price.

"post_filter": {
  "bool": {
    "must": [
      {
        "nested": {
          "query": {
            "range": {
              "price.price": {
                "from": "15",
                "to": "29",
                "include_lower": true,
                "include_upper": false,
                "boost": 1.0
              }
            }
          },
          "path": "price",
          "ignore_unmapped": false,
          "score_mode": "none",
          "boost": 1.0
        }
      },
      {
        "terms": {
          "option_text_article_type": [
            "Sous-gants"
          ],
          "boost": 1.0
        }
      },
      {
        "terms": {
          "price.customer_group_id": [
            0
          ],
          "boost": 1.0
        }
      }
    ],
    "disable_coord": false,
    "adjust_pure_negative": true,
    "boost": 1.0
  }

In the response, I get two hits with this price list for example:

"price": [
  {
    "price": 10.2,
    "original_price": 10.2,
    "is_discount": false,
    "customer_group_id": "0"
  },
  {
    "price": 10.2,
    "original_price": 10.2,
    "is_discount": false,
    "customer_group_id": "1"
  },
  {
    "price": 16.99,
    "original_price": 16.99,
    "is_discount": false,
    "customer_group_id": "2"
  },
  {
    "price": 16.99,
    "original_price": 16.99,
    "is_discount": false,
    "customer_group_id": "3"
  }
]

The issue is that I'm navigating as a customer_group_id = 0 and a price range of 15-29 and 10.2 is not part of that range. It's only part of the range for the customer_group_id : 2 or 3.

Any idea on how to fix this?

@nicobatty
Copy link
Author

It does work correctly if I change the post_filter part like this:

"post_filter": {
    "bool": {
      "must": [
        {
          "nested": {
            "query": {
              "bool": {
                "must": [
                  {
                    "range": {
                      "price.price": {
                        "from": "15",
                        "to": "29",
                        "include_lower": true,
                        "include_upper": false,
                        "boost": 1.0
                      }
                    }
                  },
                  {
                    "terms": {
                      "price.customer_group_id": [
                        0
                      ],
                      "boost": 1.0
                    }
                  }
                ]
              }
            },
            "path": "price",
            "ignore_unmapped": false,
            "score_mode": "none",
            "boost": 1.0
          }
        },
        {
          "terms": {
            "option_text_article_type": [
              "Sous-gants"
            ],
            "boost": 1.0
          }
        }
      ],
      "disable_coord": false,
      "adjust_pure_negative": true,
      "boost": 1.0
    }
  },

Though I'm not an expert in Elasticsearch so I'm not sure this would be the right way to do it.

@romainruaud romainruaud added the bug label Oct 2, 2018
@romainruaud romainruaud self-assigned this Oct 2, 2018
@romainruaud
Copy link
Collaborator

Hello @nicobatty

interesting issue, and interesting hypothesis of resolution.

Always happy to see people digging inside our engine, so thank you for submitting a such detailed issue.

I'll have a look on this one.

@romainruaud
Copy link
Collaborator

Associated PR have been merged and will be part of the next minor release.

Thank you for supporting our module !

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

2 participants