【问题标题】:ElasticSearch - how to query documents by specific field in JSON fieldElasticSearch - 如何通过 JSON 字段中的特定字段查询文档
【发布时间】:2021-05-22 03:15:47
【问题描述】:

我想“如何通过JSON字段中的特定字段查询文档?”

索引示例:

{
  "_index": "battery-2021.02.18",
  "_type": "_doc",
  "_id": "DulWt3cB6VaK5-_iGoEG",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2021-02-18T22:50:02.125Z",
    "battery_log": {
      "battery_id": "BAT80031",
      "bms": {
        "event": {
          "fault_uvp": 0,
          "fault_dc_ocp": 0,
          "fault_switch_otp": 0,
          "warning_utp": 0,
          "fault_int_otp": 0,
          "fault_c_ocp": 0,
          "warning_module_dc_utp": 1
        }
        "etc": 0
      }
    }
  }
}

我要查询battery_log.bms.event.*等于1的文档。

提前谢谢你。

【问题讨论】:

    标签: elasticsearch querydsl


    【解决方案1】:

    使用multi_match query,您可以这样做:

    POST battery-2021.02.18/_search
    {
      "query": {
        "multi_match": {
          "query": "1",
          "fields": ["battery_log.bms.event.*"]
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2020-06-19
      • 2015-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多