# How to set field values when put mapping

**URL:** <https://discuss.elastic.co/t/how-to-set-field-values-when-put-mapping/11074>\
**Category:** Elasticsearch\
**Created:** [March 8, 2013, 1:47pm UTC](https://discuss.elastic.co/t/how-to-set-field-values-when-put-mapping/11074 "2013-03-08T13:47:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jingang\_Wang](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@Jingang\_Wang](https://discuss.elastic.co/u/Jingang_Wang)\
**Post date:** [March 8, 2013, 1:47pm UTC](https://discuss.elastic.co/t/how-to-set-field-values-when-put-mapping/11074/1 "2013-03-08T13:47:07Z")

</div>

Hi guys,

The documents I want to index contains multiple fields, such as doc\_id,  
doc\_content and doc\_time.  
I just want to create index in doc\_content field. What should I do when put  
mapping for these three fields.  
For the other two fields I don't want to index, should I set "index" as  
"no" or "not\_analyzed" ?  
By the way, I want to get doc\_id and doc\_time after I conduct a query on  
doc\_content, so I keep the two fields in the mapping.

XContentBuilder mapping = jsonBuilder()  
.startObject()  
.startObject("myType")  
.startObject("properties")  
.startObject("doc\_id").field("type",  
"string").field("index","not\_analyzed").endObject()  
.startObject("doc\_content").field("type",  
"string").field("index", "not\_analyzed").endObject()

.startObject("doc\_time").field("type","string").field("index","not\_analyzed").endObject()  
.endObject()  
.endObject()  
.endObject();  
PutMappingRequest mappingRequest =  
Requests.putMappingRequest("Myindex").type("myType").source(mapping);

I used above mapping settings, the index created for 8M data is ~37M. Is it  
a normal phenomenon?  
Any help would be appreciated.

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 12, 2013, 10:48am UTC](https://discuss.elastic.co/t/how-to-set-field-values-when-put-mapping/11074/2 "2013-03-12T10:48:34Z")

</div>

Hey

On Fri, Mar 8, 2013 at 2:47 PM, Jingang Wang [bitwjg@gmail.com](mailto:bitwjg@gmail.com) wrote:

> The documents I want to index contains multiple fields, such as doc\_id,  
> doc\_content and doc\_time.  
> I just want to create index in doc\_content field. What should I do when  
> put mapping for these three fields.  
> For the other two fields I don't want to index, should I set "index" as  
> "no" or "not\_analyzed" ?

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

Setting it to "no" makes sense if you do not want to search it (however it  
is still available in the source field, if not explicitely disabled).

you might want to check  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/all-field.html) in  
order to understand a part of your big index size.

--Alexander

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:47am UTC](https://discuss.elastic.co/t/how-to-set-field-values-when-put-mapping/11074/3 "2017-07-06T02:47:00Z")

</div>


