# Document Retreive

**URL:** <https://discuss.elastic.co/t/document-retreive/116479>\
**Category:** Elasticsearch\
**Created:** [January 22, 2018, 12:17pm UTC](https://discuss.elastic.co/t/document-retreive/116479 "2018-01-22T12:17:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![devil\_srj7](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@devil\_srj7](https://discuss.elastic.co/u/devil_srj7)\
**Post date:** [January 22, 2018, 12:17pm UTC](https://discuss.elastic.co/t/document-retreive/116479/1 "2018-01-22T12:17:57Z")

</div>

I have two indices

1. index A
2. index B

both the indices has different information  
but  
each index has a field named "employee\_id"

I need to retrieve all information of a employee with id 1 from both the indices.

Since both indices have same field value employee\_id, i need

indexA.employee\_id==1

indexB.employee\_id==1 //something like this

together to be filtered

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 22, 2018, 12:38pm UTC](https://discuss.elastic.co/t/document-retreive/116479/2 "2018-01-22T12:38:24Z")

</div>

```auto
DELETE test1 
DELETE test2
PUT test1/doc/1
{
  "employee_id": 1
}
PUT test1/doc/2
{
  "employee_id": 2
}
PUT test2/doc/1
{
  "employee_id": 1
}
GET test1,test2/_search
{
  "query": {
    "term": {
      "employee_id": {
        "value": 1
      }
    }
  }
}

```

Gives:

```auto
{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 10,
    "successful": 10,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 2,
    "max_score": 1,
    "hits": [
      {
        "_index": "test1",
        "_type": "doc",
        "_id": "1",
        "_score": 1,
        "_source": {
          "employee_id": 1
        }
      },
      {
        "_index": "test2",
        "_type": "doc",
        "_id": "1",
        "_score": 1,
        "_source": {
          "employee_id": 1
        }
      }
    ]
  }
}

```

---

<div class="post-metadata">

**Author:** ![devil\_srj7](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@devil\_srj7](https://discuss.elastic.co/u/devil_srj7)\
**Post date:** [January 22, 2018, 1:25pm UTC](https://discuss.elastic.co/t/document-retreive/116479/3 "2018-01-22T13:25:25Z")

</div>

The requirement as follows.

```
 GET indexa,indexb/_search?
    {
      "_source": ["employee_id from indexa","employee_name from indexa","employee_branch from indexb","sum of salary from indexb"],
      "query": {
        "match": { 
          "employee_id": "5"
        }
      }
    }

```

I need all the information as a single record document.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 22, 2018, 1:41pm UTC](https://discuss.elastic.co/t/document-retreive/116479/4 "2018-01-22T13:41:02Z")

</div>

There is no JOIN in elasticsearch. Apart this [https://www.elastic.co/guide/en/elasticsearch/reference/6.1/parent-join.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.1/parent-join.html)

May be tell more about the use case?

---

<div class="post-metadata">

**Author:** ![devil\_srj7](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@devil\_srj7](https://discuss.elastic.co/u/devil_srj7)\
**Post date:** [January 22, 2018, 1:47pm UTC](https://discuss.elastic.co/t/document-retreive/116479/5 "2018-01-22T13:47:13Z")

</div>

> [@dadoonet](#):
>
> There is no JOIN in elasticsearch. Apart this [join datatype | Elasticsearch Reference [6.1] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/6.1/parent-join.html)

Join can be used within an Index, as I have multiple table, this is of no use to me.  
though thanks.

What do u need in usecase??

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 22, 2018, 2:12pm UTC](https://discuss.elastic.co/t/document-retreive/116479/6 "2018-01-22T14:12:24Z")

</div>

> What do u need in usecase??

What kind of problem are you trying to solve?  
If you denormalize the data, may be you can solve it?

---

<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 19, 2018, 2:12pm UTC](https://discuss.elastic.co/t/document-retreive/116479/7 "2018-02-19T14:12:27Z")

</div>

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