# Best approach to pull back only relevant fields

**URL:** <https://discuss.elastic.co/t/best-approach-to-pull-back-only-relevant-fields/21489>\
**Category:** Elasticsearch\
**Created:** [January 5, 2015, 9:50pm UTC](https://discuss.elastic.co/t/best-approach-to-pull-back-only-relevant-fields/21489 "2015-01-05T21:50:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phil\_Swenson\_2](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@Phil\_Swenson\_2](https://discuss.elastic.co/u/Phil_Swenson_2)\
**Post date:** [January 5, 2015, 9:50pm UTC](https://discuss.elastic.co/t/best-approach-to-pull-back-only-relevant-fields/21489/1 "2015-01-05T21:50:06Z")

</div>

If I have a document I’m storing that looks like this:

doc = {

userId: \*‘\*yoyomamma',  
physicians: [{  
name: "sanjay gupta",  
id: 403494  
},  
{  
name: "daniel litvak",  
id: 3382  
}],  
procedures: [{  
name: "appendectomy",  
id: 3939,  
date: "2/3/2012"  
}

… etc a bunch of other stuff

}

When I search on “appendectomy” I want to only return the following:  
“userId” and the matching “procedures” fields…..

Any thoughts on the best approach to do this?

thanks

phil

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGenvhVDwZdS8519af5RWisrEVVUbeOi55%2BUdGZNK55mwsLzNw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGenvhVDwZdS8519af5RWisrEVVUbeOi55%2BUdGZNK55mwsLzNw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2015, 6:06am UTC](https://discuss.elastic.co/t/best-approach-to-pull-back-only-relevant-fields/21489/2 "2015-01-06T06:06:40Z")

</div>

It somehow means to me that you are searching for procedures so you should index procedures not doc.

If you need both, you could may be use Parent/child feature so you will have different docs indexed.

My 2 cents

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

> Le 5 janv. 2015 à 22:50, phil swenson [phil.swenson@gmail.com](mailto:phil.swenson@gmail.com) a écrit :
> 
> If I have a document I’m storing that looks like this:
> 
> doc = {
> 
> userId: ‘yoyomamma',  
> physicians: [{  
> name: "sanjay gupta",  
> id: 403494  
> },  
> {  
> name: "daniel litvak",  
> id: 3382  
> }],  
> procedures: [{  
> name: "appendectomy",  
> id: 3939,  
> date: "2/3/2012"  
> }  
> … etc a bunch of other stuff  
> }  
> When I search on “appendectomy” I want to only return the following: “userId” and the matching “procedures” fields…..
> 
> Any thoughts on the best approach to do this?
> 
> thanks  
> phil
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGenvhVDwZdS8519af5RWisrEVVUbeOi55%2BUdGZNK55mwsLzNw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGenvhVDwZdS8519af5RWisrEVVUbeOi55%2BUdGZNK55mwsLzNw%40mail.gmail.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/00357F51-A710-4973-B428-FAAF6B17E5CB%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/00357F51-A710-4973-B428-FAAF6B17E5CB%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:40am UTC](https://discuss.elastic.co/t/best-approach-to-pull-back-only-relevant-fields/21489/3 "2017-07-06T00:40:37Z")

</div>


