问题:es查询相同文本,返回的score不同
{
"query": {
"bool": {
"must": [
{
"match": {
"shopName": "sock"
}
}
]
}
},
"sort": [
{
"_score": {
"order": "desc"
}
}
],
"_source": [
"shopId",
"shopName",
"score"
]
}
过程:百度很多说是因为分片数的原因,因为每个分片的数据不同,导致召唤回的结果不同,score也不同。
searchType查询改为DFS_QUERY_THEN_FETCH无效
解决:后来发现可能是主副本数数据不同造成的,将副本数重置后问题解决
//查看分片
curl 'ip:9200/_cat/shards'
//将副本数设置为0
curl -H "Content-Type: application/json" -XPUT 'http://ip:9200/ywgproduct/_settings' -d '
{
"number_of_replicas": 0
}
'
//
curl -H "Content-Type: application/json" -XPUT 'http://ip:9200/ywgproduct/_settings' -d '
{
"number_of_replicas": 1
}
'