# How to get field data from other documents in query?

**URL:** <https://discuss.elastic.co/t/how-to-get-field-data-from-other-documents-in-query/118188>\
**Category:** Elasticsearch\
**Created:** [February 2, 2018, 8:47am UTC](https://discuss.elastic.co/t/how-to-get-field-data-from-other-documents-in-query/118188 "2018-02-02T08:47:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Piyush\_Aggarwal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/piyush_aggarwal/32/27306_2.png) [@Piyush\_Aggarwal](https://discuss.elastic.co/u/Piyush_Aggarwal)\
**Post date:** [February 2, 2018, 8:47am UTC](https://discuss.elastic.co/t/how-to-get-field-data-from-other-documents-in-query/118188/1 "2018-02-02T08:47:57Z")

</div>

Hello everyone, I am trying to create a structure for feeds where one user can create feeds and it can see the feeds of the persons whom he/she is following, I have a feed structure mappings like this:

```
{
"properties": { 
 "key": {
      "type": "keyword"
    },
"name": {
      "type": "keyword"
    },
"annonymous":{
      "type":"boolean"
    },
"email":{
      "type": "keyword"
    },
"username":{
      "type": "text"
    },
"fullDesc": {
      "type": "text"
    },
"shortDesc": {
      "type": "text"
    },
"previewImage": {
      "type": "keyword"
    }
    "created":{
      "type":"date",
      "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
    }
  }
}

```

The user Profile structure is like this:

```
  {
    "dynamic_templates": [
        {
          "result": {
            "path_match": "result.*",
            "mapping": {
              "type": "text",
              "index": false
            }
          }
        }],
      "properties":
       {
            "email":{
              "type":"keyword"
            },
            "searchHere" : {
                "type": "text",
                "analyzer": "english",
                "fields": {
                    "noDecompound": {
                        "type": "text",
                        "analyzer": "simple"
                    },
                    "noStem": {
                        "type": "text",
                        "analyzer": "standard"
                }
            }
           }
        }
}

```

In the user profile structure the "result.\*" fields will contain the data like user profile image and name of the user which is likely to change, to search the user I will put its details in "searchHere" element .

Now when we get the feeds of the users which a particular user is following from we need the details of its followers profile to show the feeds as it will help us to plot the data in front-end easily.

Now what can I do to include the profile fields of the user while getting feeds from the feed type??

---

<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, 8:48am UTC](https://discuss.elastic.co/t/how-to-get-field-data-from-other-documents-in-query/118188/2 "2018-03-02T08:48:21Z")

</div>

Closed on March 2, 2018, 8:48am UTC

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