mapping是这样的:
数据是这样子的:
查询语句是这样子的:
如果有java API 代码更加好!!!!
数据是这样子的:
查询语句是这样子的:
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 代码更加好!!!!
3 个回复
wyntergreg
赞同来自: 这个冬天不太Cool
这个冬天不太Cool - 90后
赞同来自:
这个冬天不太Cool - 90后
赞同来自: