# Elasticsearch duplicate documents multi fields search error

**URL:** https://discuss.elastic.co/t/elasticsearch-duplicate-documents-multi-fields-search-error/118290
**Category:** Elasticsearch
**Created:** [February 2, 2018, 11:24pm UTC](https://discuss.elastic.co/t/elasticsearch-duplicate-documents-multi-fields-search-error/118290 "2018-02-02T23:24:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![databeata](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@databeata](https://discuss.elastic.co/u/databeata)
#### Post date: [February 2, 2018, 11:24pm UTC](https://discuss.elastic.co/t/elasticsearch-duplicate-documents-multi-fields-search-error/118290/1 "2018-02-02T23:24:13Z")

</div>

This search of duplicate documents for single field is working.

```
curl -XGET 'http://ip:9200/test_4/test_4/_search?pretty=true' -H 'Content-Type: application/json' -d'{
  "size": 0,
  "aggs": {
    "duplicateCount": {
      "terms": {
      "field": "date.keyword",
        "min_doc_count": 2
      },
      "aggs": {
        "duplicateDocuments": {
          "top_hits": {}
        }
      }
    }
  }
}'

```

This search of duplicate documents for multi fields is not working.

```
curl -XGET 'http://ip:9200/test_4/test_4/_search?pretty=true' -H 'Content-Type: application/json' -d'{
  "size": 0,
  "aggs": {
    "duplicateCount": {
      "terms": {
      "script": "doc['date'].values + doc['EventType'].values",
        "min_doc_count": 2
      },
      "aggs": {
        "duplicateDocuments": {
          "top_hits": {}
        }
      }
    }
  }
}'

{
  "error" : {
    "root_cause" : [
      {
        "type" : "script_exception",
        "reason" : "compile error",
        "script_stack" : [
          "doc[date].values + doc[EventT ...",
          " ^---- HERE"
        ],
        "script" : "doc[date].values + doc[EventType].values",
        "lang" : "painless"
      }
    ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query",
    "grouped" : true,
    "failed_shards" : [
      {
        "shard" : 0,
        "index" : "test_4",
        "node" : "dhB-H0_yRROhoP6W-FhOyA",
        "reason" : {
          "type" : "script_exception",
          "reason" : "compile error",
          "script_stack" : [
            "doc[date].values + doc[EventT ...",
            " ^---- HERE"
          ],
          "script" : "doc[date].values + doc[EventType].values",
          "lang" : "painless",
          "caused_by" : {
            "type" : "illegal_argument_exception",
            "reason" : "Variable [date] is not defined."
          }
        }
      }
    ]
  },
  "status" : 500
}
```

---

<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: [March 2, 2018, 11:24pm UTC](https://discuss.elastic.co/t/elasticsearch-duplicate-documents-multi-fields-search-error/118290/2 "2018-03-02T23:24:46Z")

</div>

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