在查询Elastic search时遇到了一个奇怪的问题,当通过Kibana开发工具运行时,查询给出了正确的响应,但通过Rest API命中时,给出了400错误,即找不到映射。以下是详细信息。通过Kibana dev工具查询:
获取diagnostics/_search?pretty=true&q=OTA4MjYxODM3NQ&size=6&sort=timestamp:desc
正在获取对上述查询的响应:
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 22,
"max_score": null,
"hits": [
{
.......
}
]
}但是当我通过Rest API进行同样的操作时,下面是这样的场景: API - http://IP:9200/diagnostics/_search?pretty=true&q=OTA4MjYxODM3NQ&size=6&sort=timestamp:desc
响应:
{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "No mapping found for [timestamp] in order to sort on",
"index_uuid": "JYOLtQ_URBGKnhxUWzD3dA",
"index": "diagnostics"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "diagnostics",
"node": "kisW84q1SbKEz7KQiOtY7Q",
"reason": {
"type": "query_shard_exception",
"reason": "No mapping found for [timestamp] in order to sort on",
"index_uuid": "JYOLtQ_URBGKnhxUWzD3dA",
"index": "diagnostics"
}
}
]
},
"status": 400
}请帮助我,因为我发现这非常奇怪,因为当我调用API时,通过代码,它是失败的,我被困在理解这个问题的根本原因。
获取诊断详细信息
http://IP(A):9200/diagnostics
{
"diagnostics": {
"aliases": {},
"mappings": {},
"settings": {
"index": {
"creation_date": "1613465495276",
"number_of_shards": "5",
"number_of_replicas": "0",
"uuid": "JYOLtQ_URBGKnhxUWzD3dA",
"version": {
"created": "5050199"
},
"provided_name": "diagnostics"
}
}
}
}通过运行在IP(A)上的Kibana开发工具:5601-
GET diagnostics
{
"diagnostics": {
"aliases": {},
"mappings": {
"results": {
"properties": {
details are present here....
}
"number_of_shards": "5",
"provided_name": "diagnostics",
"creation_date": "1545374854111",
"number_of_replicas": "0",
"uuid": "CB7Vci8MTNiW2F85_S4z4Q",
"version": {
"created": "5050199"
}
}
}
}
}发布于 2021-08-02 09:19:03
几乎可以肯定的是,您的Kibana指向另一个正在运行的Elasticsearch实例。
确保设置elasticsearch.hosts下的kibana.yml文件中的IP与IP(A)相同。
https://stackoverflow.com/questions/68607951
复制相似问题