# Any way to index but not save parts of the document?

**URL:** https://discuss.elastic.co/t/any-way-to-index-but-not-save-parts-of-the-document/4691
**Category:** Elasticsearch
**Created:** [June 23, 2011, 2:45pm UTC](https://discuss.elastic.co/t/any-way-to-index-but-not-save-parts-of-the-document/4691 "2011-06-23T14:45:32Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mattx](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@mattx](https://discuss.elastic.co/u/mattx)
#### Post date: [June 23, 2011, 2:45pm UTC](https://discuss.elastic.co/t/any-way-to-index-but-not-save-parts-of-the-document/4691/1 "2011-06-23T14:45:32Z")

</div>

Hi,

I'm sorry if this is documented somewhere but I cannot find it. Although I do think I remember reading it.

I want to index some email messages for search but they are already in a database so I do not want ES to save a copy of all the data (for example the body). Is there any way I can index an ENTIRE doc that looks like:

{  
dbid: 12345,  
tos: [[a@foo.com](mailto:a@foo.com), [b@foo.com](mailto:b@foo.com)],  
from: [c@foo.com](mailto:c@foo.com)  
subject: "A subject",  
body: "A body"  
}

and tell ES to only store a doc that looks like {dbid: 12345}?

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [June 24, 2011, 9:14pm UTC](https://discuss.elastic.co/t/any-way-to-index-but-not-save-parts-of-the-document/4691/2 "2011-06-24T21:14:57Z")

</div>

Hi Matt

> Is there any way I can index an ENTIRE doc that looks like:  
> and tell ES to only store a doc that looks like {dbid: 12345}?

You can disable to \_source field if you like.

> **[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.

clint

---

<div class="post-metadata">

### Author: ![mattx](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@mattx](https://discuss.elastic.co/u/mattx)
#### Post date: [June 28, 2011, 5:44pm UTC](https://discuss.elastic.co/t/any-way-to-index-but-not-save-parts-of-the-document/4691/3 "2011-06-28T17:44:00Z")

</div>

Wow. The all or nothing approach doesn't work for me. I need to be able to at least get back the document ID of the thing I am indexing. What I really need is the ability to throw away only certain fields in the \_source.

Am I being stupid? If I bulk index 100k email messages and don't include the \_source then how can I later fetch these emails after doing a search? Do I have to store the IDs generated by the indexing operation as they map to my original IDs? I don't love that idea and I'm not even sure how to do that in a bulk indexing operation.

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [June 28, 2011, 5:58pm UTC](https://discuss.elastic.co/t/any-way-to-index-but-not-save-parts-of-the-document/4691/4 "2011-06-28T17:58:16Z")

</div>

Hi Matt

On Tue, 2011-06-28 at 10:44 -0700, mattx wrote:

> Wow. The all or nothing approach doesn't work for me. I need to be able to  
> at least get back the document ID of the thing I am indexing. What I really  
> need is the ability to throw away only certain fields in the \_source.
> 
> Am I being stupid? If I bulk index 100k email messages and don't include  
> the \_source then how can I later fetch these emails after doing a search?  
> Do I have to store the IDs generated by the indexing operation as they map  
> to my original IDs? I don't love that idea and I'm not even sure how to do  
> that in a bulk indexing operation.

I don't follow what it is you are trying to do. Whether you index or  
bulk\_index you get back the ID (either the ID that you specify, or an  
autogenerated ID)

Why don't you want the \_source? Because it contains too much  
information? What about deleting the information that you don't want to  
store before indexing the email?

Perhaps a bit more context will help...

clint

---

<div class="post-metadata">

### Author: ![medcl\_net](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@medcl\_net](https://discuss.elastic.co/u/medcl_net)
#### Post date: [June 29, 2011, 4:06am UTC](https://discuss.elastic.co/t/any-way-to-index-but-not-save-parts-of-the-document/4691/5 "2011-06-29T04:06:10Z")

</div>

Hey,you can use the parameter : fields to specify which fields you are  
expected to return.

On 6/29/11, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk) wrote:

> Hi Matt
> 
> On Tue, 2011-06-28 at 10:44 -0700, mattx wrote:
> 
> > Wow. The all or nothing approach doesn't work for me. I need to be able  
> > to  
> > at least get back the document ID of the thing I am indexing. What I  
> > really  
> > need is the ability to throw away only certain fields in the \_source.
> > 
> > Am I being stupid? If I bulk index 100k email messages and don't include  
> > the \_source then how can I later fetch these emails after doing a search?  
> > Do I have to store the IDs generated by the indexing operation as they map  
> > to my original IDs? I don't love that idea and I'm not even sure how to  
> > do  
> > that in a bulk indexing operation.
> 
> I don't follow what it is you are trying to do. Whether you index or  
> bulk\_index you get back the ID (either the ID that you specify, or an  
> autogenerated ID)
> 
> Why don't you want the \_source? Because it contains too much  
> information? What about deleting the information that you don't want to  
> store before indexing the email?
> 
> Perhaps a bit more context will help...
> 
> clint

--  
从我的移动设备发送

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [June 29, 2011, 12:02pm UTC](https://discuss.elastic.co/t/any-way-to-index-but-not-save-parts-of-the-document/4691/6 "2011-06-29T12:02:31Z")

</div>

Another way is not to store the source, and specifically store certain fields (by enabling store in the mapping section for each field).

On Wednesday, June 29, 2011 at 7:06 AM, Medcl Zero wrote:

> Hey,you can use the parameter : fields to specify which fields you are  
> expected to return.
> 
> On 6/29/11, Clinton Gormley \<[clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk) ([mailto:clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk))\> wrote:
> 
> > Hi Matt
> > 
> > On Tue, 2011-06-28 at 10:44 -0700, mattx wrote:
> > 
> > > Wow. The all or nothing approach doesn't work for me. I need to be able  
> > > to  
> > > at least get back the document ID of the thing I am indexing. What I  
> > > really  
> > > need is the ability to throw away only certain fields in the \_source.
> > > 
> > > Am I being stupid? If I bulk index 100k email messages and don't include  
> > > the \_source then how can I later fetch these emails after doing a search?  
> > > Do I have to store the IDs generated by the indexing operation as they map  
> > > to my original IDs? I don't love that idea and I'm not even sure how to  
> > > do  
> > > that in a bulk indexing operation.
> > 
> > I don't follow what it is you are trying to do. Whether you index or  
> > bulk\_index you get back the ID (either the ID that you specify, or an  
> > autogenerated ID)
> > 
> > Why don't you want the \_source? Because it contains too much  
> > information? What about deleting the information that you don't want to  
> > store before indexing the email?
> > 
> > Perhaps a bit more context will help...
> > 
> > clint
> 
> --  
> 从我的移动设备发送

---

<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, 4:02am UTC](https://discuss.elastic.co/t/any-way-to-index-but-not-save-parts-of-the-document/4691/7 "2017-07-06T04:02:17Z")

</div>


