你不会是程序猿吧?

关于查询权重问题,完全命中的store 反而不怎么高

Elasticsearch | 作者 这个冬天不太Cool | 发布于2017年12月05日 | 阅读数:2320

mapping是这样的:

QQ图片20171205145523.png

 
数据是这样子的:

QQ图片20171205145642.png

 
查询语句是这样子的:
POST http://localhost:9200/robot/_search
{
"query":{
"term":{
"question":"你"
}
}
}
返回结果如下:
 
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 4,
"max_score": 1.3626978,
"hits": [
{
"_index": "robot",
"_type": "brain",
"_id": "AWAklKdUEXHi548SCMvK",
"_score": 1.3626978,
"_source": {
"question": "你是不是从石头里蹦出来的",
"answer": "你才是从石头里蹦出来的",
"create_time": "2017-12-05 10:50:10",
"user_id": ""
}
},
{
"_index": "robot",
"_type": "brain",
"_id": "AWAkwMmAEXHi548SCMvO",
"_score": 0.8630463,
"_source": {
"question": "你",
"answer": "你什么你,我叫逗比",
"create_time": "2017-12-05 11:38:22",
"user_id": "1"
}
},
{
"_index": "robot",
"_type": "brain",
"_id": "AWAkh-NBEXHi548SCMvF",
"_score": 0.63332754,
"_source": {
"question": "你",
"answer": "我什么我,我是不是很帅",
"create_time": "2017-12-05 10:36:13",
"user_id": "1"
}
},
{
"_index": "robot",
"_type": "brain",
"_id": "AWAkiUh7EXHi548SCMvG",
"_score": 0.4243027,
"_source": {
"question": "你好",
"answer": "你好我好大家好",
"create_time": "2017-12-05 10:37:44",
"user_id": "1"
}
}
]
}
}
我想问,这查询语句应该怎么写才是正确的呢,按理说question 完全命中了,都没有在前,这个权重应该怎么设置才对呢?求大神解答!
如果有java API 代码更加好!!!!
 
已邀请:

这个冬天不太Cool - 90后

赞同来自:

我想把完全名字question 的数据放在最前面,应该怎么实现。

这个冬天不太Cool - 90后

赞同来自:

# 这样查询也不行,返回结果和上面的一样
{
"query" : {
"constant_score" : {
"filter" : {
"term" : {
"question" : "你"
}
}
}
}
}

要回复问题请先登录注册