如何在elasticsearch中基于关键字字段进行查询

vpfxa7rd  于 2021-06-15  发布在  ElasticSearch
关注(0)|答案(1)|浏览(354)
"test": {
           "124": {
                    "folders": [
                                {
                                    "unread_count": 0,
                                    "custom": 0,
                                    "id": 2
                                },
                                {
                                    "unread_count": 1,
                                    "custom": 0,
                                    "default_tag": 1,
                                    "id": 3
                                }
                            ],
                            "scans": [
                                {
                                    "folder_id": 3,
                                    "type": "local",
                                    "uuid": "4cf2531f-0d85-3a47-6262-",
                                    "id": 375
                                }
                                ]

                            }
                    }

查询test和124字段是否存在,id:375是否存在,扫描结果相同。如果存在的话。
我还没有找到任何资料可以根据字段进行查询,有什么方法吗。已尝试使用must查询,但存在返回空结果的操作。

fnx2tebb

fnx2tebb1#

我很肯定你的数据会更干净,但你可以这样做。如果您的用例不简单,您可能会对此有问题。

{
  "query": {
    "multi_match" : {
      "query":    375, 
      "fields": [ "test.*.id"] 
    }
  }
}

相关问题