Jakarta ee 是什么导致两个节点上相同弹性搜索查询的搜索结果不同
我有一个两节点弹性搜索设置,其中一个节点上的相同搜索查询会产生与另一个节点不同的结果,我想找出原因。详情:Jakarta ee 是什么导致两个节点上相同弹性搜索查询的搜索结果不同,jakarta-ee,
elasticsearch,Jakarta Ee,
elasticsearch,我有一个两节点弹性搜索设置,其中一个节点上的相同搜索查询会产生与另一个节点不同的结果,我想找出原因。详情: 相同的文档(内容和id相同)在两个节点上的分数不同,导致排序顺序不同 它是可复制的:我可以删除整个索引并从数据库中重建它,但结果仍然不同 两个es节点部署在java ee war中。在每次部署中,都会从数据库重建索引 最初发现问题时,同一查询的hits.total结果在两个节点上不同。在我删除并重建索引后,它们是相同的 我现在的解决方法是按照建议使用 到目前为止,我在日志中找不到任何有趣
- 相同的文档(内容和id相同)在两个节点上的分数不同,导致排序顺序不同
- 它是可复制的:我可以删除整个索引并从数据库中重建它,但结果仍然不同
- 两个es节点部署在java ee war中。在每次部署中,都会从数据库重建索引
- 最初发现问题时,同一查询的hits.total结果在两个节点上不同。在我删除并重建索引后,它们是相同的
- 我现在的解决方法是按照建议使用
- 到目前为止,我在日志中找不到任何有趣的错误
{
"cluster_name": "elasticsearch.abc",
"version": 330,
"master_node": "HexGKOoHSxqRaMmwduCVIA",
"blocks": {},
"nodes": {
"rUZDrUfMR1-RWcy4t0YQNw": {
"name": "Owl",
"transport_address": "inet[/10.123.123.123:9303]",
"attributes": {}
},
"HexGKOoHSxqRaMmwduCVIA": {
"name": "Bloodlust II",
"transport_address": "inet[/10.123.123.124:9303]",
"attributes": {}
}
},
"metadata": {
"templates": {},
"indices": {
"abc": {
"state": "open",
"settings": {
"index": {
"creation_date": "1432297566361",
"uuid": "LKx6Ro9CRXq6JZ9a29jWeA",
"analysis": {
"filter": {
"substring": {
"type": "nGram",
"min_gram": "1",
"max_gram": "50"
}
},
"analyzer": {
"str_index_analyzer": {
"filter": [
"lowercase",
"substring"
],
"tokenizer": "keyword"
},
"str_search_analyzer": {
"filter": [
"lowercase"
],
"tokenizer": "keyword"
}
}
},
"number_of_replicas": "1",
"number_of_shards": "5",
"version": {
"created": "1050099"
}
}
},
"mappings": {
"some_mapping": {
...
}
...
},
"aliases": []
}
}
},
"routing_table": {
"indices": {
"abc": {
"shards": {
"0": [
{
"state": "STARTED",
"primary": true,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 0,
"index": "abc"
},
{
"state": "STARTED",
"primary": false,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 0,
"index": "abc"
}
],
"1": [
{
"state": "STARTED",
"primary": false,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 1,
"index": "abc"
},
{
"state": "STARTED",
"primary": true,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 1,
"index": "abc"
}
],
"2": [
{
"state": "STARTED",
"primary": true,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 2,
"index": "abc"
},
{
"state": "STARTED",
"primary": false,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 2,
"index": "abc"
}
],
"3": [
{
"state": "STARTED",
"primary": false,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 3,
"index": "abc"
},
{
"state": "STARTED",
"primary": true,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 3,
"index": "abc"
}
],
"4": [
{
"state": "STARTED",
"primary": true,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 4,
"index": "abc"
},
{
"state": "STARTED",
"primary": false,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 4,
"index": "abc"
}
]
}
}
}
},
"routing_nodes": {
"unassigned": [],
"nodes": {
"HexGKOoHSxqRaMmwduCVIA": [
{
"state": "STARTED",
"primary": true,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 4,
"index": "abc"
},
{
"state": "STARTED",
"primary": true,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 0,
"index": "abc"
},
{
"state": "STARTED",
"primary": false,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 3,
"index": "abc"
},
{
"state": "STARTED",
"primary": false,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 1,
"index": "abc"
},
{
"state": "STARTED",
"primary": true,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 2,
"index": "abc"
}
],
"rUZDrUfMR1-RWcy4t0YQNw": [
{
"state": "STARTED",
"primary": false,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 4,
"index": "abc"
},
{
"state": "STARTED",
"primary": false,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 0,
"index": "abc"
},
{
"state": "STARTED",
"primary": true,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 3,
"index": "abc"
},
{
"state": "STARTED",
"primary": true,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 1,
"index": "abc"
},
{
"state": "STARTED",
"primary": false,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 2,
"index": "abc"
}
]
}
},
"allocations": []
}
/_search?from=22&size=1
{
"query": {
"bool": {
"should": [{
"match": {
"address.city": {
"query": "Bremen",
"boost": 2
}
}
}],
"must": [{
"match": {
"type": "L"
}
}]
}
}
}
\u集群/健康
{
"cluster_name": "elasticsearch.abc",
"status": "green",
"timed_out": false,
"number_of_nodes": 2,
"number_of_data_nodes": 2,
"active_primary_shards": 5,
"active_shards": 10,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0,
"number_of_pending_tasks": 0
}
\u集群/stats
{
"timestamp": 1432312770877,
"cluster_name": "elasticsearch.abc",
"status": "green",
"indices": {
"count": 1,
"shards": {
"total": 10,
"primaries": 5,
"replication": 1,
"index": {
"shards": {
"min": 10,
"max": 10,
"avg": 10
},
"primaries": {
"min": 5,
"max": 5,
"avg": 5
},
"replication": {
"min": 1,
"max": 1,
"avg": 1
}
}
},
"docs": {
"count": 19965,
"deleted": 4
},
"store": {
"size_in_bytes": 399318082,
"throttle_time_in_millis": 0
},
"fielddata": {
"memory_size_in_bytes": 60772,
"evictions": 0
},
"filter_cache": {
"memory_size_in_bytes": 15284,
"evictions": 0
},
"id_cache": {
"memory_size_in_bytes": 0
},
"completion": {
"size_in_bytes": 0
},
"segments": {
"count": 68,
"memory_in_bytes": 10079288,
"index_writer_memory_in_bytes": 0,
"index_writer_max_memory_in_bytes": 5120000,
"version_map_memory_in_bytes": 0,
"fixed_bit_set_memory_in_bytes": 0
},
"percolate": {
"total": 0,
"time_in_millis": 0,
"current": 0,
"memory_size_in_bytes": -1,
"memory_size": "-1b",
"queries": 0
}
},
"nodes": {
"count": {
"total": 2,
"master_only": 0,
"data_only": 0,
"master_data": 2,
"client": 0
},
"versions": [
"1.5.0"
],
"os": {
"available_processors": 8,
"mem": {
"total_in_bytes": 0
},
"cpu": []
},
"process": {
"cpu": {
"percent": 0
},
"open_file_descriptors": {
"min": 649,
"max": 654,
"avg": 651
}
},
"jvm": {
"max_uptime_in_millis": 2718272183,
"versions": [
{
"version": "1.7.0_40",
"vm_name": "Java HotSpot(TM) 64-Bit Server VM",
"vm_version": "24.0-b56",
"vm_vendor": "Oracle Corporation",
"count": 2
}
],
"mem": {
"heap_used_in_bytes": 2665186528,
"heap_max_in_bytes": 4060086272
},
"threads": 670
},
"fs": {
"total_in_bytes": 631353901056,
"free_in_bytes": 209591468032,
"available_in_bytes": 209591468032
},
"plugins": []
}
}
查询示例:
{
"cluster_name": "elasticsearch.abc",
"version": 330,
"master_node": "HexGKOoHSxqRaMmwduCVIA",
"blocks": {},
"nodes": {
"rUZDrUfMR1-RWcy4t0YQNw": {
"name": "Owl",
"transport_address": "inet[/10.123.123.123:9303]",
"attributes": {}
},
"HexGKOoHSxqRaMmwduCVIA": {
"name": "Bloodlust II",
"transport_address": "inet[/10.123.123.124:9303]",
"attributes": {}
}
},
"metadata": {
"templates": {},
"indices": {
"abc": {
"state": "open",
"settings": {
"index": {
"creation_date": "1432297566361",
"uuid": "LKx6Ro9CRXq6JZ9a29jWeA",
"analysis": {
"filter": {
"substring": {
"type": "nGram",
"min_gram": "1",
"max_gram": "50"
}
},
"analyzer": {
"str_index_analyzer": {
"filter": [
"lowercase",
"substring"
],
"tokenizer": "keyword"
},
"str_search_analyzer": {
"filter": [
"lowercase"
],
"tokenizer": "keyword"
}
}
},
"number_of_replicas": "1",
"number_of_shards": "5",
"version": {
"created": "1050099"
}
}
},
"mappings": {
"some_mapping": {
...
}
...
},
"aliases": []
}
}
},
"routing_table": {
"indices": {
"abc": {
"shards": {
"0": [
{
"state": "STARTED",
"primary": true,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 0,
"index": "abc"
},
{
"state": "STARTED",
"primary": false,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 0,
"index": "abc"
}
],
"1": [
{
"state": "STARTED",
"primary": false,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 1,
"index": "abc"
},
{
"state": "STARTED",
"primary": true,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 1,
"index": "abc"
}
],
"2": [
{
"state": "STARTED",
"primary": true,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 2,
"index": "abc"
},
{
"state": "STARTED",
"primary": false,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 2,
"index": "abc"
}
],
"3": [
{
"state": "STARTED",
"primary": false,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 3,
"index": "abc"
},
{
"state": "STARTED",
"primary": true,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 3,
"index": "abc"
}
],
"4": [
{
"state": "STARTED",
"primary": true,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 4,
"index": "abc"
},
{
"state": "STARTED",
"primary": false,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 4,
"index": "abc"
}
]
}
}
}
},
"routing_nodes": {
"unassigned": [],
"nodes": {
"HexGKOoHSxqRaMmwduCVIA": [
{
"state": "STARTED",
"primary": true,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 4,
"index": "abc"
},
{
"state": "STARTED",
"primary": true,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 0,
"index": "abc"
},
{
"state": "STARTED",
"primary": false,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 3,
"index": "abc"
},
{
"state": "STARTED",
"primary": false,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 1,
"index": "abc"
},
{
"state": "STARTED",
"primary": true,
"node": "HexGKOoHSxqRaMmwduCVIA",
"relocating_node": null,
"shard": 2,
"index": "abc"
}
],
"rUZDrUfMR1-RWcy4t0YQNw": [
{
"state": "STARTED",
"primary": false,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 4,
"index": "abc"
},
{
"state": "STARTED",
"primary": false,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 0,
"index": "abc"
},
{
"state": "STARTED",
"primary": true,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 3,
"index": "abc"
},
{
"state": "STARTED",
"primary": true,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 1,
"index": "abc"
},
{
"state": "STARTED",
"primary": false,
"node": "rUZDrUfMR1-RWcy4t0YQNw",
"relocating_node": null,
"shard": 2,
"index": "abc"
}
]
}
},
"allocations": []
}
/_search?from=22&size=1
{
"query": {
"bool": {
"should": [{
"match": {
"address.city": {
"query": "Bremen",
"boost": 2
}
}
}],
"must": [{
"match": {
"type": "L"
}
}]
}
}
}
对第一个请求的响应
{
"took": 30,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 19543,
"max_score": 6.407021,
"hits": [{
"_index": "abc",
"_type": "xyz",
"_id": "ABC123",
"_score": 5.8341036,
"_source": {
...
}
}]
}
}
{
"took": 27,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 19543,
"max_score": 6.407021,
"hits": [
{
"_index": "abc",
"_type": "xyz",
"_id": "FGH12343",
"_score": 5.8341036,
"_source": {
...
}
}
]
}
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 41,
"max_score": 7.211497,
"hits": [
{
"_shard": 0,
"_node": "rUZDrUfMR1-RWcy4t0YQNw",
"_index": "abc",
"_type": "mytype",
"_id": "abc123",
"_score": 7.211497,
"_source": {...
},
"_explanation": {
"value": 7.211497,
"description": "weight(address.city:karlsruhe^2.0 in 1598) [PerFieldSimilarity], result of:",
"details": [
{
"value": 7.211497,
"description": "fieldWeight in 1598, product of:",
"details": [
{
"value": 1,
"description": "tf(freq=1.0), with freq of:",
"details": [
{
"value": 1,
"description": "termFreq=1.0"
}
]
},
{
"value": 7.211497,
"description": "idf(docFreq=46, maxDocs=23427)"
},
{
"value": 1,
"description": "fieldNorm(doc=1598)"
}
]
}
]
}
}
]
}
}
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 41,
"max_score": 7.194322,
"hits": [
{
"_shard": 0,
"_node": "rUZDrUfMR1-RWcy4t0YQNw",
"_index": "abc",
"_type": "mytype",
"_id": "abc123",
"_score": 7.194322,
"_source": {...
},
"_explanation": {
"value": 7.194322,
"description": "weight(address.city:karlsruhe^2.0 in 1598) [PerFieldSimilarity], result of:",
"details": [
{
"value": 7.194322,
"description": "fieldWeight in 1598, product of:",
"details": [
{
"value": 1,
"description": "tf(freq=1.0), with freq of:",
"details": [
{
"value": 1,
"description": "termFreq=1.0"
}
]
},
{
"value": 7.194322,
"description": "idf(docFreq=48, maxDocs=24008)"
},
{
"value": 1,
"description": "fieldNorm(doc=1598)"
}
]
}
]
}
}
]
}
}
对第二个请求的响应
{
"took": 30,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 19543,
"max_score": 6.407021,
"hits": [{
"_index": "abc",
"_type": "xyz",
"_id": "ABC123",
"_score": 5.8341036,
"_source": {
...
}
}]
}
}
{
"took": 27,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 19543,
"max_score": 6.407021,
"hits": [
{
"_index": "abc",
"_type": "xyz",
"_id": "FGH12343",
"_score": 5.8341036,
"_source": {
...
}
}
]
}
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 41,
"max_score": 7.211497,
"hits": [
{
"_shard": 0,
"_node": "rUZDrUfMR1-RWcy4t0YQNw",
"_index": "abc",
"_type": "mytype",
"_id": "abc123",
"_score": 7.211497,
"_source": {...
},
"_explanation": {
"value": 7.211497,
"description": "weight(address.city:karlsruhe^2.0 in 1598) [PerFieldSimilarity], result of:",
"details": [
{
"value": 7.211497,
"description": "fieldWeight in 1598, product of:",
"details": [
{
"value": 1,
"description": "tf(freq=1.0), with freq of:",
"details": [
{
"value": 1,
"description": "termFreq=1.0"
}
]
},
{
"value": 7.211497,
"description": "idf(docFreq=46, maxDocs=23427)"
},
{
"value": 1,
"description": "fieldNorm(doc=1598)"
}
]
}
]
}
}
]
}
}
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 41,
"max_score": 7.194322,
"hits": [
{
"_shard": 0,
"_node": "rUZDrUfMR1-RWcy4t0YQNw",
"_index": "abc",
"_type": "mytype",
"_id": "abc123",
"_score": 7.194322,
"_source": {...
},
"_explanation": {
"value": 7.194322,
"description": "weight(address.city:karlsruhe^2.0 in 1598) [PerFieldSimilarity], result of:",
"details": [
{
"value": 7.194322,
"description": "fieldWeight in 1598, product of:",
"details": [
{
"value": 1,
"description": "tf(freq=1.0), with freq of:",
"details": [
{
"value": 1,
"description": "termFreq=1.0"
}
]
},
{
"value": 7.194322,
"description": "idf(docFreq=48, maxDocs=24008)"
},
{
"value": 1,
"description": "fieldNorm(doc=1598)"
}
]
}
]
}
}
]
}
}
}
原因可能是什么?如何确保不同节点的结果相同
按要求解释查询:search/abc/mytype/\u search?from=0&size=1&search\u type=dfs\u query\u然后\u fetch&explain=
{
"query": {
"bool": {
"should": [{
"match": {
"address.city": {
"query": "Karlsruhe",
"boost": 2
}
}
}]
}
}
}
对第一个请求的响应
{
"took": 30,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 19543,
"max_score": 6.407021,
"hits": [{
"_index": "abc",
"_type": "xyz",
"_id": "ABC123",
"_score": 5.8341036,
"_source": {
...
}
}]
}
}
{
"took": 27,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 19543,
"max_score": 6.407021,
"hits": [
{
"_index": "abc",
"_type": "xyz",
"_id": "FGH12343",
"_score": 5.8341036,
"_source": {
...
}
}
]
}
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 41,
"max_score": 7.211497,
"hits": [
{
"_shard": 0,
"_node": "rUZDrUfMR1-RWcy4t0YQNw",
"_index": "abc",
"_type": "mytype",
"_id": "abc123",
"_score": 7.211497,
"_source": {...
},
"_explanation": {
"value": 7.211497,
"description": "weight(address.city:karlsruhe^2.0 in 1598) [PerFieldSimilarity], result of:",
"details": [
{
"value": 7.211497,
"description": "fieldWeight in 1598, product of:",
"details": [
{
"value": 1,
"description": "tf(freq=1.0), with freq of:",
"details": [
{
"value": 1,
"description": "termFreq=1.0"
}
]
},
{
"value": 7.211497,
"description": "idf(docFreq=46, maxDocs=23427)"
},
{
"value": 1,
"description": "fieldNorm(doc=1598)"
}
]
}
]
}
}
]
}
}
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 41,
"max_score": 7.194322,
"hits": [
{
"_shard": 0,
"_node": "rUZDrUfMR1-RWcy4t0YQNw",
"_index": "abc",
"_type": "mytype",
"_id": "abc123",
"_score": 7.194322,
"_source": {...
},
"_explanation": {
"value": 7.194322,
"description": "weight(address.city:karlsruhe^2.0 in 1598) [PerFieldSimilarity], result of:",
"details": [
{
"value": 7.194322,
"description": "fieldWeight in 1598, product of:",
"details": [
{
"value": 1,
"description": "tf(freq=1.0), with freq of:",
"details": [
{
"value": 1,
"description": "termFreq=1.0"
}
]
},
{
"value": 7.194322,
"description": "idf(docFreq=48, maxDocs=24008)"
},
{
"value": 1,
"description": "fieldNorm(doc=1598)"
}
]
}
]
}
}
]
}
}
对第二个请求的响应
{
"took": 30,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 19543,
"max_score": 6.407021,
"hits": [{
"_index": "abc",
"_type": "xyz",
"_id": "ABC123",
"_score": 5.8341036,
"_source": {
...
}
}]
}
}
{
"took": 27,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 19543,
"max_score": 6.407021,
"hits": [
{
"_index": "abc",
"_type": "xyz",
"_id": "FGH12343",
"_score": 5.8341036,
"_source": {
...
}
}
]
}
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 41,
"max_score": 7.211497,
"hits": [
{
"_shard": 0,
"_node": "rUZDrUfMR1-RWcy4t0YQNw",
"_index": "abc",
"_type": "mytype",
"_id": "abc123",
"_score": 7.211497,
"_source": {...
},
"_explanation": {
"value": 7.211497,
"description": "weight(address.city:karlsruhe^2.0 in 1598) [PerFieldSimilarity], result of:",
"details": [
{
"value": 7.211497,
"description": "fieldWeight in 1598, product of:",
"details": [
{
"value": 1,
"description": "tf(freq=1.0), with freq of:",
"details": [
{
"value": 1,
"description": "termFreq=1.0"
}
]
},
{
"value": 7.211497,
"description": "idf(docFreq=46, maxDocs=23427)"
},
{
"value": 1,
"description": "fieldNorm(doc=1598)"
}
]
}
]
}
}
]
}
}
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 41,
"max_score": 7.194322,
"hits": [
{
"_shard": 0,
"_node": "rUZDrUfMR1-RWcy4t0YQNw",
"_index": "abc",
"_type": "mytype",
"_id": "abc123",
"_score": 7.194322,
"_source": {...
},
"_explanation": {
"value": 7.194322,
"description": "weight(address.city:karlsruhe^2.0 in 1598) [PerFieldSimilarity], result of:",
"details": [
{
"value": 7.194322,
"description": "fieldWeight in 1598, product of:",
"details": [
{
"value": 1,
"description": "tf(freq=1.0), with freq of:",
"details": [
{
"value": 1,
"description": "termFreq=1.0"
}
]
},
{
"value": 7.194322,
"description": "idf(docFreq=48, maxDocs=24008)"
},
{
"value": 1,
"description": "fieldNorm(doc=1598)"
}
]
}
]
}
}
]
}
}
命中不匹配很可能是因为主碎片和副本之间不同步。如果某个节点离开集群(无论出于何种原因),但不断更改文档(索引、删除、更新),则可能会发生这种情况 评分部分是一个不同的故事,可以通过以下“相关性评分”部分进行解释: Elasticsearch在执行搜索时面临着一个有趣的困境。您的查询需要找到所有相关文档……但是这些文档分散在集群中的任何数量的碎片上。 每个碎片基本上是一个Lucene索引,它维护自己的TF和DF统计数据。碎片只知道“菠萝”在碎片中出现了多少次,而不是整个集群 在搜索时,我会尝试使用“DFS查询然后获取”,意思是
\u搜索?搜索类型=DFS\u查询\u然后获取….
,这将有助于提高评分的准确性
此外,由于节点断开连接期间的文档更改而导致的文档计数不同,甚至在删除和重建索引之后,也会影响分数计算。这可能是因为对文档的更改在副本和主碎片上发生的方式不同,更具体地说,文档已被删除。已删除的文档将在合并时从索引中永久删除。除非底层Lucene实例满足某些条件,否则段合并不会发生
强制合并可以通过发布到
/\u optimize?max\u num\u segments=1
来启动。警告:这需要很长时间(取决于索引的大小),需要大量IO资源和CPU,不应在正在进行更改的索引上运行。文档:,谢谢,将您的答案标记为有用,但仍有一些未决问题:点击错误匹配:群集状态始终为绿色。专家们不会注意到大脑分裂的情况吗?在这种情况下,像文档总数这样明显的事情是不同的?dfs:与无参数相比,该参数更改了分数/顺序,但仍然不同。max_score 5.751141 vs 5.633818-我现在添加了排序(按_score,_uid)并获得与更改分数一致的排序,这留下了为什么分数仍然不同的问题。不,ES没有“注意”不同的文档计数。此外,大脑分裂也没有引起注意。为了避免大脑分裂,你们需要确保你们的配置是正确的,并防止这种情况发生。ES不会主动地对分裂的大脑做任何事情,这是用户的工作。您的配置文件中是否设置了最小\u主\u节点
“我现在添加了排序(按分数,\u uid)并通过更改分数获得一致的排序,这就留下了分数保持不同的问题。”我不明白您在说什么。我有两个节点的设置,无法更改此设置。有了两个节点的设置,我无法避免大脑分裂。所以我想我应该添加一个监控功能。据我所知,带有dfs的博客文章\u query\u然后\u fetch连续两次触发相同的查询,结果应该是一致的。我不是这样的。第一个响应将包含“最大分数”:5.6822467第二个响应将包含“最大分数”:5.6968164。两次都发送相同的查询,两次都使用相同的url参数:/\u search?from=0&size=50&search\u type=dfs\u query\u然后\u fetch如果最小主节点设置为2,则可以避免大脑分裂。这意味着,如果一个节点发生故障,那么集群将被卡住(它将需要第二个节点继续进行主节点选举)。两次查询执行中得分最高的文档是否相同?