Bad order with scripted sort and nested filter

Hello, I have problems. When I am using nested filter in my query sorting order breaks (without nested filters works perfect )

{
  "query": {
    "nested": {
      "path": "status",
      "query": {
        "bool": {
          "should": [
            {
              "match": {
                "status.isOk": true
              }
            }
          ]
        }
      }
    }
  },
  "sort": [
    {
      "_script": {
        "script": {
          "source": "doc['price'].value", //example only
          "lang": "painless"
        },
        "type": "number",
        "order": "asc",
        "nested": {
          "path" : "params",
          "filter":{
            "bool": {
              "must": [ 
                {
                  "range": {
                    "params.date1": {
                      "from": null,
                      "to": "2021-09-09",
                      "include_lower": true,
                      "include_upper": true,
                      "boost": 1
                    }
                  }
                },
                {
                  "range": {
                    "params.date12": {
                      "from": "2021-09-09",
                      "to": null,
                      "include_lower": true,
                      "include_upper": true,
                      "boost": 1
                    }
                  }
                }
              ],
              "adjust_pure_negative": true,
              "boost": 1
            }
          }
        }
      }
    }
  ]
}

Hey,

please provide a reproducible but minimal example as well as error messages. Just seeing a query without indexing or mapping is not helpful for debugging.

Thank you!

--Alex

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.