Elasticsearch日期范围过滤器更改分数

时间:2015-08-05 00:18:25

标签: elasticsearch lucene

使用下面的查询,删除must会返回一些与使用范围相同的项目但分数因此排名不同。好像日期过滤器正在改变分数。我不希望这样,我只是希望过滤器限制返回的内容而不重新排序它们。

有没有办法按日期过滤不影响分数或排名?

{
    "size": 10,
    "query": {
        "bool": {
            "should": [{
                "terms": {
                    "title": ["surface", "ipad", "nexus"]
                }
            }, {
                "terms": {
                    "tags": ["mobile_acc"]
                }
            }],
            "must": [{
                "constant_score": {
                    "filter": {
                        "range": {
                            "availabledate": {
                                "lte": "2015-08-30T12:24:41-07:00"
                            }
                        }
                    }
                }
            }, {
                "constant_score": {
                    "filter": {
                        "range": {
                            "expiredate": {
                                "gt": "2015-08-30T12:24:41-07:00"
                            }
                        }
                    }
                }
            }]
        }
    }
}

1 个答案:

答案 0 :(得分:1)

"boost": 0添加constant_score

  "must": [
    {
      "constant_score": {
        "filter": {
          "range": {
            "availabledate": {
              "lte": "2015-08-30T12:24:41-07:00"
            }
          }
        },
        "boost": 0
      }
    },
    {
      "constant_score": {
        "filter": {
          "range": {
            "expiredate": {
              "gt": "2015-08-30T12:24:41-07:00"
            }
          }
        },
        "boost": 0
      }
    }
  ]