弹性搜索 - query_shard_exception |找不到 [timestamp] 的映射以便通过 kibana 开发工具对 on-Works 进行排序,但通过 API 出现 400 错误

ElasticSearch - query_shard_exception | No mapping found for [timestamp] in order to sort on-Works through kibana dev tools but 400 error through API

在查询 Elastic 搜索时遇到一个奇怪的问题,当通过 Kibana 开发工具 运行 时查询给出了正确的响应,但通过 Rest API 时给出了 400 错误,未找到映射。以下是详细信息。 通过 Kibana 开发工具查询:

GET 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"
            }
        }
    }
}

通过 Kibana 开发工具 运行在 IP(A):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"
        }
      }
    }
  }
}

几乎可以肯定您的 Kibana 指向另一个 运行 Elasticsearch 实例。

确保设置elasticsearch.hosts下的kibana.yml文件中的IP与IP(A)相同。