# Is it possible to combine two docs in different indices?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-combine-two-docs-in-different-indices/276035>\
**Category:** Elasticsearch\
**Tags:** transforms\
**Created:** [June 15, 2021, 5:04pm UTC](https://discuss.elastic.co/t/is-it-possible-to-combine-two-docs-in-different-indices/276035 "2021-06-15T17:04:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![attiley](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@attiley](https://discuss.elastic.co/u/attiley)\
**Post date:** [June 15, 2021, 5:04pm UTC](https://discuss.elastic.co/t/is-it-possible-to-combine-two-docs-in-different-indices/276035/1 "2021-06-15T17:04:04Z")

</div>

Hello guys!  
If I have two docs in two different indices.  
One doc in index "content" is like this

```auto
{
    "id": "content_id",
    "content": random content,
    "user_details":{
      "user_id":"123"
      }
}

```

and another doc in another index "user\_info" is like this

```auto
{
    "id": "user_info_id",
     "user_id": "123,
     "avatar" : "https://xxx.xxx",
     "username" : "xxxx"
}

```

Can I combine these two docs filtered by field "user\_id" like this? Just like $lookup in MongoDb?

```auto
{
    "id": "content_id",
    "content": random content,
    "user_details":{
      "user_id":"123"
      "avatar" : "https://xxx.xxx",
      "username" : "xxxx"
      }
}

```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 15, 2021, 10:03pm UTC](https://discuss.elastic.co/t/is-it-possible-to-combine-two-docs-in-different-indices/276035/2 "2021-06-15T22:03:45Z")

</div>

Welcome to our community! 😃  
We aren't all guys though 🙂

You should be able to do this with a Transform - [Transforming data | Elasticsearch Guide [7.13] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/transforms.html). Otherwise you will want to merge both documents before sending to Elasticsearch.

---

<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:** [July 13, 2021, 10:03pm UTC](https://discuss.elastic.co/t/is-it-possible-to-combine-two-docs-in-different-indices/276035/3 "2021-07-13T22:03:56Z")

</div>

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