如何编写查询?

2024-09-27 01:22:17 发布

您现在位置:Python中文网/ 问答频道 /正文

"search_id" : "7f2d683165",
          "uploaded_time" : "2019-05-10 15:25:35.373",
          "processing_end_time" : "2019-05-10 15:25:38.115",
          "batches" : {
            "5cd598617026837753891a2b" : {
              "is_reviewed" : false,
              "batch_name" : "T--45"
            }
          }

如果我想要("is_reviewed" : true),我如何编写正确的查询?
我试过这个:

query={"query": { "nested" : {"path" : "batches","query" : {"bool" : {"should" : [ { "match" : {"batches.is_reviewed" : true} }]}}}}}

res=es.search(index="cool",body={"query":{"match":{"pass":"true"}}})

我只想要输出"pass:true"


Tags: idfalsetruesearchtimeismatchbatch
1条回答
网友
1楼 · 发布于 2024-09-27 01:22:17

您可以尝试以下方法之一:

{
  "query": {
    "query_string": {
      "query": "batches.\\*.is_reviewed:true"
    }
  }
}

或者如果batchesnested

{
  "query": {
    "nested": {
      "path": "batches",
      "query": {
        "bool": {
          "should": [
            {
              "query_string": {
                "query": "batches.\\*.is_reviewed:true"
              }
            }
          ]
        }
      }
    }
  }
}

相关问题 更多 >

    热门问题