我发送的查询如下:(使用查询{all})
{
"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
作为我的提升点的总和,并且只显示包含术语的结果?
SearchService :https://gist.github.com/8f13ce2be820d9ef1959
答案 0 :(得分:0)
从es docs看起来像:
看起来得分为16的文档(来自match_all
查询)与第二次搜索中的"query_string":{"query":"ruby php"}
不匹配,这就是max_score
较少的原因。
另外你说16,是你所有提升点的总和,但是当我将得分加起来时我得到25分,或者如果你包括黑名单那么-75 ...