# \[Question\] Field Mapping while indexing

**URL:** <https://discuss.elastic.co/t/question-field-mapping-while-indexing/15664>\
**Category:** Elasticsearch\
**Created:** [February 7, 2014, 9:20am UTC](https://discuss.elastic.co/t/question-field-mapping-while-indexing/15664 "2014-02-07T09:20:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srividhya\_Umashanker](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Srividhya\_Umashanker](https://discuss.elastic.co/u/Srividhya_Umashanker)\
**Post date:** [February 7, 2014, 9:20am UTC](https://discuss.elastic.co/t/question-field-mapping-while-indexing/15664/1 "2014-02-07T09:20:07Z")

</div>

All -

I am working on a POC to replace Lucene implementation in our product with  
ElasticSearch.

Was looking for a way in Elasticsearch to create an object and setting the  
field's Indexing behavior (i.e, store, type, index\_type) dynamically while  
indexing a document.  
I understand that that you can create a mapping per index defining the  
behavior. Is there a way to achieve something similar to the way we do it  
in lucene as shown below?

* * *

//create lucene document and add fields and their indexing attributes  
Document doc = new Document();

Field field = new Field("name", "name1", Field.Store.YES,  
Field.Index.NOT\_ANALYZED);  
doc.add(field);

field = new Field("address", "address", Field.Store.YES,  
Field.Index.DO\_NOT\_INDEX);  
doc.add(field);

writer.updateDocument(term, doc);

* * *

-Vidhya

--  
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/79a5f1c0-d783-4aea-aa42-6462c737b8d7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/79a5f1c0-d783-4aea-aa42-6462c737b8d7%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [February 7, 2014, 11:59am UTC](https://discuss.elastic.co/t/question-field-mapping-while-indexing/15664/2 "2014-02-07T11:59:56Z")

</div>

My bet is that you are looking for templates or so?

Not sure I fully understood the use case though.

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

Le 7 févr. 2014 à 10:20, Srividhya Umashanker [srividhya.umashanker@gmail.com](mailto:srividhya.umashanker@gmail.com) a écrit :

> All -
> 
> I am working on a POC to replace Lucene implementation in our product with Elasticsearch.
> 
> Was looking for a way in Elasticsearch to create an object and setting the field's Indexing behavior (i.e, store, type, index\_type) dynamically while indexing a document.  
> I understand that that you can create a mapping per index defining the behavior. Is there a way to achieve something similar to the way we do it in lucene as shown below?
> 
> * * *
> 
> //create lucene document and add fields and their indexing attributes  
> Document doc = new Document();
> 
> Field field = new Field("name", "name1", Field.Store.YES, Field.Index.NOT\_ANALYZED);  
> doc.add(field);
> 
> field = new Field("address", "address", Field.Store.YES, Field.Index.DO\_NOT\_INDEX);  
> doc.add(field);
> 
> writer.updateDocument(term, doc);
> 
> * * *
> 
> ## -Vidhya
> 
> 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/79a5f1c0-d783-4aea-aa42-6462c737b8d7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/79a5f1c0-d783-4aea-aa42-6462c737b8d7%40googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/849FD880-7CC0-4033-811A-E0522DA5D53A%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/849FD880-7CC0-4033-811A-E0522DA5D53A%40pilato.fr).  
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, 1:51am UTC](https://discuss.elastic.co/t/question-field-mapping-while-indexing/15664/3 "2017-07-06T01:51:49Z")

</div>


