Combined_fields + dfs_query_then_fetch causes error

Using combined_fields query with dfs_query_then_fetch causes "docCount must not exceed maxDoc" error if the request goes to multiple shards. Quick example to reproduce the issue
(Elasticsearch v7.13.4, v7.15.0)

PUT /my-index
{
  "settings": {
    "index": {
      "number_of_shards": 2 
    }
  }
}

POST /my-index/_doc
{
  "name": "item 1",
  "description": "description 1"
}
POST /my-index/_doc
{
  "name": "item 2",
  "description": "description 2"
}

POST /my-index/_search?search_type=dfs_query_then_fetch
{
  "query": {
    "combined_fields": {
      "fields": [
        "name", "description"
      ],
      "query": "item"
    }
  }
}

Response:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "docCount must not exceed maxDoc, docCount: 2, maxDoc: 1"
      }
    ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "dfs_query",
    "grouped" : true,
    "failed_shards" : [
      {
        "shard" : 0,
        "index" : "my-index",
        "node" : "iieOmNBaRkaOGjyQCQw6Bg",
        "reason" : {
          "type" : "illegal_argument_exception",
          "reason" : "docCount must not exceed maxDoc, docCount: 2, maxDoc: 1"
        }
      }
    ],
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "docCount must not exceed maxDoc, docCount: 2, maxDoc: 1",
      "caused_by" : {
        "type" : "illegal_argument_exception",
        "reason" : "docCount must not exceed maxDoc, docCount: 2, maxDoc: 1"
      }
    }
  },
  "status" : 400
}

Thanks for catching this @cyradin! Could you please file a GitHub issue in our repo (GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine) so we can track and address the bug?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.