# Merge different index in function two fields and paste eleement of fields

**URL:** <https://discuss.elastic.co/t/merge-different-index-in-function-two-fields-and-paste-eleement-of-fields/293363>\
**Category:** Elasticsearch\
**Created:** [January 3, 2022, 3:35pm UTC](https://discuss.elastic.co/t/merge-different-index-in-function-two-fields-and-paste-eleement-of-fields/293363 "2022-01-03T15:35:37Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Vivian](https://avatars.discourse-cdn.com/v4/letter/v/3e96dc/32.png) [@Vivian](https://discuss.elastic.co/u/Vivian)\
**Post date:** [January 4, 2022, 2:54pm UTC](https://discuss.elastic.co/t/merge-different-index-in-function-two-fields-and-paste-eleement-of-fields/293363/5 "2022-01-04T14:54:43Z")

</div>

That's the idea and to eliminate redundant information I am inspired by this post ([Merging documents based on matched fields values](https://discuss.elastic.co/t/merging-documents-based-on-matched-fields-values/249728) , , I work on siren investigate, I managed to make my aggregation as below :

```auto
GET df_extrait/_search?size=0
{
"aggs": {
    "my composite": {
      "composite": {
        "sources": [
          {
            "source_principal": {
              "terms": {
                "field": "source.keyword"
              }
            }
          },
          {
            "target_principal": {
              "terms": {
                "field": "target.keyword"
              }
            }
          }
        ]
        
      }
    }
  }

```

When I try to create a new index in this way I get this error:

 ![Screenshot from 2022-01-04 09-53-48](https://us1.discourse-cdn.com/elastic/original/3X/2/a/2a68518512934d99c517f9fd42797c575985d7cb.png)

---

_[View the full topic](https://discuss.elastic.co/t/merge-different-index-in-function-two-fields-and-paste-eleement-of-fields/293363)._
