# Return just the Json document id

**URL:** <https://discuss.elastic.co/t/return-just-the-json-document-id/7919>\
**Category:** Elasticsearch\
**Created:** [May 30, 2012, 7:12pm UTC](https://discuss.elastic.co/t/return-just-the-json-document-id/7919 "2012-05-30T19:12:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [May 30, 2012, 7:12pm UTC](https://discuss.elastic.co/t/return-just-the-json-document-id/7919/1 "2012-05-30T19:12:47Z")

</div>

We are planning to index Json document that could be as big as 200K. When  
user executes search we just want the matching doc id instead of the entire  
documents. How can I just get the id of the Json 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:** [May 30, 2012, 7:23pm UTC](https://discuss.elastic.co/t/return-just-the-json-document-id/7919/2 "2012-05-30T19:23:03Z")

</div>

Don't store source.

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Le 30 mai 2012 à 21:12, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :

> We are planning to index Json document that could be as big as 200K. When user executes search we just want the matching doc id instead of the entire documents. How can I just get the id of the Json document?

---

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [May 30, 2012, 7:38pm UTC](https://discuss.elastic.co/t/return-just-the-json-document-id/7919/3 "2012-05-30T19:38:25Z")

</div>

On Wed, May 30, 2012 at 12:23 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Don't store source.  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/source-field.html)
> 
> If I do store some portions of \_source is it possible to fetch only few  
> fields instead of fetching all of them which seems to be the default?

> Le 30 mai 2012 à 21:12, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :
> 
> We are planning to index Json document that could be as big as 200K.  
> When user executes search we just want the matching doc id instead of the  
> entire documents. How can I just get the id of the Json 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:** [May 30, 2012, 7:45pm UTC](https://discuss.elastic.co/t/return-just-the-json-document-id/7919/4 "2012-05-30T19:45:52Z")

</div>

Yes. For each field you can set store to yes : [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)

Then, you will be able to get it back (but not as a partial document).

HTH  
David

Le 30 mai 2012 à 21:38, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :

> On Wed, May 30, 2012 at 12:23 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> Don't store source.  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/source-field.html)
> 
> If I do store some portions of \_source is it possible to fetch only few fields instead of fetching all of them which seems to be the default?
> 
> Le 30 mai 2012 à 21:12, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :
> 
> > We are planning to index Json document that could be as big as 200K. When user executes search we just want the matching doc id instead of the entire documents. How can I just get the id of the Json document?

---

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [May 30, 2012, 7:54pm UTC](https://discuss.elastic.co/t/return-just-the-json-document-id/7919/5 "2012-05-30T19:54:41Z")

</div>

On Wed, May 30, 2012 at 12:45 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Yes. For each field you can set store to yes :  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)
> 
> Then, you will be able to get it back (but not as a partial document).

Thanks! How does it work for nested document. If I specify it on the parent  
does it store all the child elements too?

> HTH  
> David
> 
> Le 30 mai 2012 à 21:38, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :
> 
> On Wed, May 30, 2012 at 12:23 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> 
> > Don't store source.  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/source-field.html)
> > 
> > If I do store some portions of \_source is it possible to fetch only few  
> > fields instead of fetching all of them which seems to be the default?
> 
> > Le 30 mai 2012 à 21:12, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :
> > 
> > We are planning to index Json document that could be as big as 200K.  
> > When user executes search we just want the matching doc id instead of the  
> > entire documents. How can I just get the id of the Json 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:** [May 30, 2012, 8:12pm UTC](https://discuss.elastic.co/t/return-just-the-json-document-id/7919/6 "2012-05-30T20:12:38Z")

</div>

I don't know. I never used nested.

Sorry 😉

Le 30 mai 2012 à 21:54, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :

> On Wed, May 30, 2012 at 12:45 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> Yes. For each field you can set store to yes : [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)
> 
> Then, you will be able to get it back (but not as a partial document).
> 
> Thanks! How does it work for nested document. If I specify it on the parent does it store all the child elements too?
> 
> HTH  
> David
> 
> Le 30 mai 2012 à 21:38, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :
> 
> > On Wed, May 30, 2012 at 12:23 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> > Don't store source.  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/source-field.html)
> > 
> > If I do store some portions of \_source is it possible to fetch only few fields instead of fetching all of them which seems to be the default?
> > 
> > Le 30 mai 2012 à 21:12, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :
> > 
> > > We are planning to index Json document that could be as big as 200K. When user executes search we just want the matching doc id instead of the entire documents. How can I just get the id of the Json document?

---

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [May 30, 2012, 8:48pm UTC](https://discuss.elastic.co/t/return-just-the-json-document-id/7919/7 "2012-05-30T20:48:54Z")

</div>

Thanks! I'll try it out and see how it goes

On Wed, May 30, 2012 at 1:12 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> I don't know. I never used nested.
> 
> Sorry 😉
> 
> Le 30 mai 2012 à 21:54, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :
> 
> On Wed, May 30, 2012 at 12:45 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> 
> > Yes. For each field you can set store to yes :  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)
> > 
> > Then, you will be able to get it back (but not as a partial document).
> 
> Thanks! How does it work for nested document. If I specify it on the  
> parent does it store all the child elements too?
> 
> > HTH  
> > David
> > 
> > Le 30 mai 2012 à 21:38, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :
> > 
> > On Wed, May 30, 2012 at 12:23 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> > 
> > > Don't store source.  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/source-field.html)
> > > 
> > > If I do store some portions of \_source is it possible to fetch only few  
> > > fields instead of fetching all of them which seems to be the default?
> > 
> > > Le 30 mai 2012 à 21:12, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) a écrit :
> > > 
> > > We are planning to index Json document that could be as big as 200K.  
> > > When user executes search we just want the matching doc id instead of the  
> > > entire documents. How can I just get the id of the Json document?

---

<div class="post-metadata">

**Author:** ![jschelle](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@jschelle](https://discuss.elastic.co/u/jschelle)\
**Post date:** [October 11, 2012, 10:12pm UTC](https://discuss.elastic.co/t/return-just-the-json-document-id/7919/8 "2012-10-11T22:12:04Z")

</div>

You also use partial fields to tell it what to return. Passing an empty {} list will give you just the \_id and \_type fields.

[http://www.elasticsearch.org/guide/reference/api/search/fields.html](http://www.elasticsearch.org/guide/reference/api/search/fields.html)

---

<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, 3:09am UTC](https://discuss.elastic.co/t/return-just-the-json-document-id/7919/9 "2017-07-06T03:09:13Z")

</div>


