# Whats the best way to add mappings programmatically?

**URL:** <https://discuss.elastic.co/t/whats-the-best-way-to-add-mappings-programmatically/23691>\
**Category:** Elasticsearch\
**Created:** [May 26, 2015, 2:07pm UTC](https://discuss.elastic.co/t/whats-the-best-way-to-add-mappings-programmatically/23691 "2015-05-26T14:07:47Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![mooky](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@mooky](https://discuss.elastic.co/u/mooky)\
**Post date:** [June 1, 2015, 4:27pm UTC](https://discuss.elastic.co/t/whats-the-best-way-to-add-mappings-programmatically/23691/3 "2015-06-01T16:27:14Z")

</div>

I am primarily indexing structured data - so typically, there are many  
fields.  
In my experience mapping changes quite a bit over time - as requirements  
evolve - or as you discover the mistakes you have made.  
Your mapping necessarily refers to fields - as does your code. So, keeping  
those two in sync over time sucks.

(I have raised the same question  
here: [https://discuss.elastic.co/t/whats-the-best-way-to-configure-mappings-programmatically/](https://discuss.elastic.co/t/whats-the-best-way-to-configure-mappings-programmatically/)  
)

-Nick

On Thursday, 28 May 2015 07:51:20 UTC+1, Jason Wee wrote:

> mapping is not something you add/change every second or hour? just  
> curious, why would you want to do it programmatically?
> 
> the discussion have been moved to [https://discuss.elastic.co/](https://discuss.elastic.co/) , you might  
> get more response there.
> 
> jason
> 
> On Tue, May 26, 2015 at 10:07 PM, mooky \<[nick.mi...@gmail.com](mailto:nick.mi...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > I've been using elastic since about 2009 ... and I've always found myself  
> > embedding elastic into our app - and configuring it programmatically.  
> > I've always found programmatically configuring the mapping for an index  
> > to be very clunky.
> > 
> > But perhaps I just havent paid close attention to the enhancements over  
> > the years and I am now Doing It Wrong.
> > 
> > So, what is the best/cleanest way to configure mappings programmatically?
> > 
> > ## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)
> > 
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/b2536cd4-fa9b-4a94-8d24-09bbb0f648af%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b2536cd4-fa9b-4a94-8d24-09bbb0f648af%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/b2536cd4-fa9b-4a94-8d24-09bbb0f648af%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b2536cd4-fa9b-4a94-8d24-09bbb0f648af%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)

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/be69bcc2-c447-4e33-b2a8-01865e6f2b1b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/be69bcc2-c447-4e33-b2a8-01865e6f2b1b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

_[View the full topic](https://discuss.elastic.co/t/whats-the-best-way-to-add-mappings-programmatically/23691)._
