# Mappings for "store" do not work

**URL:** <https://discuss.elastic.co/t/mappings-for-store-do-not-work/3130>\
**Category:** Elasticsearch\
**Created:** [July 20, 2010, 11:55pm UTC](https://discuss.elastic.co/t/mappings-for-store-do-not-work/3130 "2010-07-20T23:55:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Chang](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@John\_Chang](https://discuss.elastic.co/u/John_Chang)\
**Post date:** [July 20, 2010, 11:55pm UTC](https://discuss.elastic.co/t/mappings-for-store-do-not-work/3130/1 "2010-07-20T23:55:19Z")

</div>

I have created mappings for my index to tell the service not to sore certain fields. However, when I do a GET on the id of the document, I still the the value for that field.

Indexing a document, I declare the "body" field as:  
"body" : {  
"index\_name": "body",  
"type": "string",  
"index": "analyzed",  
"store": "no"  
}

But when I do a search ([http://localhost:9200/index0/document/2036e745da914b55b56027c2c8eaa021](http://localhost:9200/index0/document/2036e745da914b55b56027c2c8eaa021)) the body is still visible.

I don't want to to keep the body for security reasons. This is an issue for me for numerous fields across numerous document types I index. What can i do to make these valuables searchable, but not stored and not readable, in Elastic Search?

Thanks

---

<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:** [July 20, 2010, 11:57pm UTC](https://discuss.elastic.co/t/mappings-for-store-do-not-work/3130/2 "2010-07-20T23:57:28Z")

</div>

Do you mean that it is returned as part of the \_source response? Fields by  
default are not stored, but the actual json document used to index is  
stored, which can be disabled by controlling the \_source mapping.

-shay.banon

On Wed, Jul 21, 2010 at 2:55 AM, John Chang [jchangkihtest2@gmail.com](mailto:jchangkihtest2@gmail.com)wrote:

> I have created mappings for my index to tell the service not to sore  
> certain  
> fields. However, when I do a GET on the id of the document, I still the  
> the  
> value for that field.
> 
> Indexing a document, I declare the "body" field as:  
> "body" : {  
> "index\_name": "body",  
> "type": "string",  
> "index": "analyzed",  
> "store": "no"  
> }
> 
> But when I do a search  
> ([http://localhost:9200/index0/document/2036e745da914b55b56027c2c8eaa021](http://localhost:9200/index0/document/2036e745da914b55b56027c2c8eaa021))  
> the  
> body is still visible.
> 
> I don't want to to keep the body for security reasons. This is an issue  
> for  
> me for numerous fields across numerous document types I index. What can i  
> do to make these valuables searchable, but not stored and not readable, in  
> Elastic Search?
> 
> ## Thanks
> 
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Mappings-for-store-do-not-work-tp982897p982897.html](http://elasticsearch-users.115913.n3.nabble.com/Mappings-for-store-do-not-work-tp982897p982897.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![John\_Chang](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@John\_Chang](https://discuss.elastic.co/u/John_Chang)\
**Post date:** [July 21, 2010, 5:23pm UTC](https://discuss.elastic.co/t/mappings-for-store-do-not-work/3130/3 "2010-07-21T17:23:45Z")

</div>

How can I get at the fields I've mapped at "store" : "yes" when I've disabled the source?

You are right, it was the \_source where I was seeing the stored json document, and I need to make sure I'm not holding on to that. So, I used the "\_source" mapping as you advised:

curl -XPUT [http://localhost:9200/index0/document/\_mapping](http://localhost:9200/index0/document/_mapping) -d '  
{  
"document" : {  
"\_source" : {"enabled" : false},

It gets rid of the source json, but now I can't get anything from the document other than the ID. (I can get the id on the org.elasticsearch.search.SearchHit objects in the org.elasticsearch.search.SearchHits list in org.elasticsearch.action.search.SearchResponse.)

I want to still be able to get at some of the fields (those I mapped as "store" : "yes"). Disabling the source, I of course now get nulls from these methods on org.elasticsearch.search.SearchHit:  
sourceAsMap() (what I had been calling before disabling source)  
getSource()  
And I get empty maps back from these methods on org.elasticsearch.search.SearchHit:  
getFields()  
getHighlightFields()  
fields()

Thanks,  
John

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [July 21, 2010, 5:32pm UTC](https://discuss.elastic.co/t/mappings-for-store-do-not-work/3130/4 "2010-07-21T17:32:49Z")

</div>

Hi John,

I think what you are after now can be found here:  
[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/)

[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/)Check the  
Request body - Fields:

{  
"fields" : ["user", "postDate"],

```
"query" : {

    "term" : { "user" : "kimchy" }

}

```

}

Regards,  
Lukas

On Wed, Jul 21, 2010 at 7:23 PM, John Chang [jchangkihtest2@gmail.com](mailto:jchangkihtest2@gmail.com)wrote:

> How can I get at the fields I've mapped at "store" : "yes" when I've  
> disabled  
> the source?
> 
> You are right, it was the \_source where I was seeing the stored json  
> document, and I need to make sure I'm not holding on to that. So, I used  
> the "\_source" mapping as you advised:
> 
> curl -XPUT [http://localhost:9200/index0/document/\_mapping](http://localhost:9200/index0/document/_mapping) -d '  
> {  
> "document" : {  
> "\_source" : {"enabled" : false},
> 
> It gets rid of the source json, but now I can't get anything from the  
> document other than the ID. (I can get the id on the  
> org.elasticsearch.search.SearchHit objects in the  
> org.elasticsearch.search.SearchHits list in  
> org.elasticsearch.action.search.SearchResponse.)
> 
> I want to still be able to get at some of the fields (those I mapped as  
> "store" : "yes"). Disabling the source, I of course now get nulls from  
> these methods on org.elasticsearch.search.SearchHit:  
> sourceAsMap() (what I had been calling before disabling source)  
> getSource()  
> And I get empty maps back from these methods on  
> org.elasticsearch.search.SearchHit:  
> getFields()  
> getHighlightFields()  
> fields()
> 
> ## Thanks, John
> 
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Mappings-for-store-do-not-work-tp982897p984900.html](http://elasticsearch-users.115913.n3.nabble.com/Mappings-for-store-do-not-work-tp982897p984900.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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:21am UTC](https://discuss.elastic.co/t/mappings-for-store-do-not-work/3130/5 "2017-07-06T04:21:53Z")

</div>


