我如何理解哪个查询返回了作为 elasticsearch 中应该查询的结果返回的文档?

How can I understand with which query the documents returned as a result of the should query in elasticsearch are returned?

我有如下查询。这里我的minimum_should_match值为1。很多“text”值为“car”或“year”值为“2019”的文档都可以return。在这里,我想找出作为此查询结果 returned 的文档是由哪个查询 returned 的。我如何在 elasticsearch 中执行此操作?

GET my_index/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "term": {
            "text": {
              "value": "car"
            }
          }
        },
        {
          "term": {
            "rank": {
              "value": "2"
            }
          }
        },
        {
          "term": {
            "year": {
              "value": "2019"
            }
          }
        }
      ],
      "minimum_should_match": 1
    }
  }
}

命名查询可能适合您 - https://www.elastic.co/guide/en/elasticsearch/reference/7.17//query-dsl-bool-query.html#named-queries