# Combined\_fields + dfs\_query\_then\_fetch causes error

**URL:** <https://discuss.elastic.co/t/combined-fields-dfs-query-then-fetch-causes-error/294410>\
**Category:** Elasticsearch\
**Created:** [January 14, 2022, 12:46pm UTC](https://discuss.elastic.co/t/combined-fields-dfs-query-then-fetch-causes-error/294410 "2022-01-14T12:46:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cyradin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cyradin/32/93891_2.png) [@cyradin](https://discuss.elastic.co/u/cyradin)\
**Post date:** [January 14, 2022, 12:46pm UTC](https://discuss.elastic.co/t/combined-fields-dfs-query-then-fetch-causes-error/294410/1 "2022-01-14T12:46:35Z")

</div>

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)

```auto
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:

```auto
{
  "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
}

```

---

<div class="post-metadata">

**Author:** ![Julie\_Tibshirani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/julie_tibshirani/32/55628_2.png) [@Julie\_Tibshirani](https://discuss.elastic.co/u/Julie_Tibshirani)\
**Post date:** [January 18, 2022, 9:40pm UTC](https://discuss.elastic.co/t/combined-fields-dfs-query-then-fetch-causes-error/294410/2 "2022-01-18T21:40:13Z")

</div>

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](https://github.com/elastic/elasticsearch)) so we can track and address the bug?

---

<div class="post-metadata">

**Author:** ![cyradin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cyradin/32/93891_2.png) [@cyradin](https://discuss.elastic.co/u/cyradin)\
**Post date:** [January 19, 2022, 5:04pm UTC](https://discuss.elastic.co/t/combined-fields-dfs-query-then-fetch-causes-error/294410/3 "2022-01-19T17:04:46Z")

</div>

> <https://github.com/elastic/elasticsearch/issues/82817>
>
> \<!--
> GitHub is reserved for bug reports and feature requests; it is not the pla…ce
> for general questions. If you have a question or an unconfirmed bug , please
> visit the \[forums\](https://discuss.elastic.co/c/elasticsearch). Please also
> check your OS is \[supported\](https://www.elastic.co/support/matrix#show\_os).
> If it is not, the issue is likely to be closed.
> 
> For security vulnerabilities please only send reports to security@elastic.co.
> See https://www.elastic.co/community/security for more information.
> 
> Please fill in the following details to help us reproduce the bug:
> \--\>
> 
> \*\*Elasticsearch version\*\* (\`bin/elasticsearch --version\`): docker image elasticsearch:7.13.4, also tried on 7.15.0
> 
> \*\*Plugins installed\*\*: \[analysis-icu, analysis-phonetic\]
> 
> \*\*JVM version\*\* (\`java -version\`): ???
> 
> \*\*OS version\*\* (\`uname -a\` if on a Unix-like system): official docker image
> 
> \*\*Description of the problem including expected versus actual behavior\*\*:
> Using combined\_fields query with dfs\_query\_then\_fetch causes "docCount must not exceed maxDoc" error if the request goes to multiple shards.
> 
> \*\*Steps to reproduce\*\*:
> Example:
> \`\`\`
> 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"
> }
> \`\`\`
> 
> 
> \*\*Provide logs (if relevant)\*\*:
> 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
> }
> \`\`\`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 16, 2022, 5:05pm UTC](https://discuss.elastic.co/t/combined-fields-dfs-query-then-fetch-causes-error/294410/4 "2022-02-16T17:05:12Z")

</div>

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