# 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:** 4\
**Page:** 1

<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:** [May 26, 2015, 2:07pm UTC](https://discuss.elastic.co/t/whats-the-best-way-to-add-mappings-programmatically/23691/1 "2015-05-26T14:07:47Z")

</div>

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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
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).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)\
**Post date:** [May 28, 2015, 6:51am UTC](https://discuss.elastic.co/t/whats-the-best-way-to-add-mappings-programmatically/23691/2 "2015-05-28T06:51:06Z")

</div>

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.minutello@gmail.com](mailto:nick.minutello@gmail.com) 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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> 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/CAHO4itw4%2Bi7XhWFHthff1rMOL1t144tBRjqyw6sf5LDtHhongg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAHO4itw4%2Bi7XhWFHthff1rMOL1t144tBRjqyw6sf5LDtHhongg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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).

---

<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, 12:10am UTC](https://discuss.elastic.co/t/whats-the-best-way-to-add-mappings-programmatically/23691/4 "2017-07-06T00:10:25Z")

</div>


