Range matching date when it should not

I have a query that should not match a range date (from what I understand) but it does:

{
    "_score": 2,
  "_source": {
    "newUntil": "2019-01-14T12:45:27+00:00",
    "searchWeightFactor": 1,
    "active": true
  },
  "_explanation": {
    "value": 2,
    "description": "sum of:",
    "details": [
      {
        "value": 2,
        "description": "sum of",
        "details": [
          {
            "value": 0,
            "description": "sum of:",
            "details": [
              {
                "value": 0,
                "description": "match on required clause, product of:",
                "details": [
                  {
                    "value": 0,
                    "description": "# clause",
                    "details": []
                  },
                  {
                    "value": 1,
                    "description": "searchStrategy:default",
                    "details": []
                  }
                ]
              },
              {
                "value": 0,
                "description": "match on required clause, product of:",
                "details": [
                  {
                    "value": 0,
                    "description": "# clause",
                    "details": []
                  },
                  {
                    "value": 1,
                    "description": "active:true",
                    "details": []
                  }
                ]
              }
            ]
          },
          {
            "value": 2,
            "description": "min of:",
            "details": [
              {
                "value": 2,
                "description": "function score, score mode [multiply]",
                "details": [
                  {
                    "value": 1,
                    "description": "script score function, computed with script:\"Script{type=inline, lang='painless', idOrCode='return 1;', options={}, params={}}\" and parameters: \n{}",
                    "details": [
                      {
                        "value": 0,
                        "description": "_score: ",
                        "details": [
                          {
                            "value": 0,
                            "description": "sum of:",
                            "details": [
                              {
                                "value": 0,
                                "description": "match on required clause, product of:",
                                "details": [
                                  {
                                    "value": 0,
                                    "description": "# clause",
                                    "details": []
                                  },
                                  {
                                    "value": 1,
                                    "description": "searchStrategy:default",
                                    "details": []
                                  }
                                ]
                              },
                              {
                                "value": 0,
                                "description": "match on required clause, product of:",
                                "details": [
                                  {
                                    "value": 0,
                                    "description": "# clause",
                                    "details": []
                                  },
                                  {
                                    "value": 1,
                                    "description": "active:true",
                                    "details": []
                                  }
                                ]
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "value": 2,
                    "description": "function score, product of:",
                    "details": [
                      {
                        "value": 1,
                        "description": "match filter: newUntil:[2019-05-17T21:29:20+00:00 TO *]",
                        "details": []
                      },
                      {
                        "value": 2,
                        "description": "product of:",
                        "details": [
                          {
                            "value": 1,
                            "description": "constant score 1.0 - no function provided",
                            "details": []
                          },
                          {
                            "value": 2,
                            "description": "weight",
                            "details": []
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "value": 1,
                    "description": "field value function: none(doc['searchWeightFactor'].value * factor=1.0)",
                    "details": []
                  }
                ]
              },
              {
                "value": 3.4028235e+38,
                "description": "maxBoost",
                "details": []
              }
            ]
          }
        ]
      },
      {
        "value": 0,
        "description": "match on required clause, product of:",
        "details": [
          {
            "value": 0,
            "description": "# clause",
            "details": []
          },
          {
            "value": 1,
            "description": "DocValuesFieldExistsQuery [field=_primary_term]",
            "details": []
          }
        ]
      }
    ]
  }
}

The part I causing issue is this part:

match filter: newUntil:[2019-05-17T21:29:20+00:00 TO *]

It's executed like it match but you can see the source and the value is

"newUntil": "2019-01-14T12:45:27+00:00",

so it should not match !

I am using Elastic Search via Amazon 6.3

Here is the query itself, it doesn't have any term in the query so we boost the score base on the newUntil date and a document weight, some field have been remove from the document above because of the size limit of a post.

{
  "query": {
    "function_score": {
      "boost_mode": "sum",
      "query": {
        "bool": {
          "filter": [
            {
              "query_string": {
                "query": "default",
                "fields": [
                  "searchStrategy"
                ]
              }
            },
            {
              "term": {
                "active": {
                  "value": true,
                  "boost": 1
                }
              }
            },
            {
              "script": {
                "script": {
                  "source": "\n                    if(doc['publishedUntil'].size() != 0 && doc['publishedUntil'].value.getMillis() <= params.now) { \n                        return false; \n                    }\n                    \n                    if(doc['publishedSince'].size() != 0 && doc['publishedSince'].value.getMillis() > params.now) { \n                        return false;\n                    } \n                    \n                    return true;\n                    ",
                  "params": {
                    "now": 1558128560000
                  },
                  "lang": "painless"
                }
              }
            }
          ]
        }
      },
      "functions": [
        {
          "script_score": {
            "script": {
              "source": "return 1;",
              "lang": "painless"
            }
          }
        },
        {
          "weight": 2,
          "filter": {
            "range": {
              "newUntil": {
                "gte": "2019-05-17T21:29:20+00:00"
              }
            }
          }
        },
        {
          "field_value_factor": {
            "field": "searchWeightFactor",
            "factor": 1
          }
        }
      ]
    }
  },
  "from": 0,
  "size": 10,
  "explain": true
}

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