首页 > 解决方案 > 谁能帮我从弹性搜索中查询

问题描述

我想访问图像中的航班数组并获取 10 x 10 的记录。我通过映射航班数组尝试了不​​同的方法。这是我在邮递员中尝试过的

 PUT http://12.234.17.134:9200/index-flights
    {
      "mappings": {
        "properties": {
          "flights": {
            "type": "nested" 
          }
        }
      }
    }
    GET http://12.234.17.134:9200/index-flights/_search
    { 
    "query": {
        "match": {
          "result.id": "2erfc096-3db0-4817-88fc-69db286e95b8"
        },
        "query": {
       "nested": {
          "path": "flights"
       }
        }
      }
     }

我的数据结构的图像

https://i.stack.imgur.com/K378p.png

标签: elasticsearchkibana

解决方案


进行_id查询 - 不需要嵌套查询(如果格式错误):

{
  "query": {
    "terms": {
      "_id": [
        "2erfc096-3db0-4817-88fc-69db286e95b8"
      ]
    }
  }
}

或者

{
  "query": {
    "ids": {
      "values": [
        "2erfc096-3db0-4817-88fc-69db286e95b8"
      ]
    }
  }
}

提示:切勿在在线论坛中共享公共集群 IP。


推荐阅读