0

我正在发送这样的查询:(使用查询{全部})

{
  "query": {
    "custom_filters_score": {
      "query": {
        "match_all": {}
      },
      "filters": [
        {
          "filter": {
            "range": {
              "last_contact_at": {
                "gte": "2013-06-21T12:02:25Z"
              }
            }
          },
          "boost": 1
        },
        {
          "filter": {
            "range": {
              "available_at": {
                "gte": "2013-06-28"
              }
            }
          },
          "boost": 2
        },
        {
          "filter": {
            "term": {
              "company_type": "intern"
            }
          },
          "boost": 10
        },
        {
          "filter": {
            "range": {
              "friends_count": {
                "from": 1
              }
            }
          },
          "boost": 3
        },
        {
          "filter": {
            "term": {
              "blacklisted": true
            }
          },
          "boost": -100
        },
        {
          "filter": {
            "term": {
              "focuses": "ruby php"
            }
          },
          "boost": 5
        },
        {
          "filter": {
            "term": {
              "tags": "ruby php"
            }
          },
          "boost": 4
        }
      ],
      "score_mode": "total"
    }
  }
}

我得到以下响应 max_score: 16 这是我的提升点的总和。

回复

{
   "took": 3,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 10,
      "max_score": 16,
...

当我发送相同的 custom_filters_score 但查询 { string term }

{
  "query": {
    "custom_filters_score": {
      "query": {
        "query_string": {
          "query": "ruby php"
        }
      },
      "filters": [
        {
          "filter": {
            "range": {
              "last_contact_at": {
                "gte": "2013-06-21T12:03:46Z"
              }
            }
          },
          "boost": 1
        },
        {
          "filter": {
            "range": {
              "available_at": {
                "gte": "2013-06-28"
              }
            }
          },
          "boost": 2
        },
        {
          "filter": {
            "term": {
              "company_type": "intern"
            }
          },
          "boost": 10
        },
        {
          "filter": {
            "range": {
              "friends_count": {
                "from": 1
              }
            }
          },
          "boost": 3
        },
        {
          "filter": {
            "term": {
              "blacklisted": true
            }
          },
          "boost": -100
        },
        {
          "filter": {
            "term": {
              "focuses": "ruby php"
            }
          },
          "boost": 5
        },
        {
          "filter": {
            "term": {
              "tags": "ruby php"
            }
          },
          "boost": 4
        }
      ],
      "score_mode": "total"
    }
  }
}

我得到 max_score 的以下响应:8.990471

回复

{
   "took": 4,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 6,
      "max_score": 8.990471,
...

如何达到max_score我的提升点的总和,并且只显示包含 term 的结果?

搜索服务:https : //gist.github.com/8f13ce2be820d9ef1959

4

1 回答 1

0

es 文档看,它看起来像:

  1. 运行查询并生成一组命中
  2. 过滤器在命中集上运行,为它们打分。

看起来得分为 16(来自match_all查询)的文档与您的第二次搜索中的不匹配"query_string":{"query":"ruby php"},这就是为什么max_score少。

您还说 16 是您所有提升点的总和,但是当我将过滤器的分数加起来时,我得到 25,或者如果您包括黑名单,则为 -75...

于 2013-06-30T06:13:50.453 回答