# \_mapping API throws IndexMissingException even with examples from ES site

**URL:** <https://discuss.elastic.co/t/-mapping-api-throws-indexmissingexception-even-with-examples-from-es-site/15494>\
**Category:** Elasticsearch\
**Created:** [January 30, 2014, 10:13am UTC](https://discuss.elastic.co/t/-mapping-api-throws-indexmissingexception-even-with-examples-from-es-site/15494 "2014-01-30T10:13:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pitty\_the\_fools](https://avatars.discourse-cdn.com/v4/letter/p/51bf81/32.png) [@pitty\_the\_fools](https://discuss.elastic.co/u/pitty_the_fools)\
**Post date:** [January 30, 2014, 10:13am UTC](https://discuss.elastic.co/t/-mapping-api-throws-indexmissingexception-even-with-examples-from-es-site/15494/1 "2014-01-30T10:13:33Z")

</div>

Hi guys and gals,

I have come across a curious problem, possibly a bug while working with  
mappings this morning. It's been a few months since I have had to create  
any mapping but created series of PHP scripts to do so a few months ago.  
Everything worked great until my latest upgrade to 0.90.10, now when I run  
my scripts I get error 404 IndexMissingException. So I checked using the  
mappings suggested in the ES documentation specifically:

$ curl -XPUT '[http://localhost:9200/twitter/tweet/\_mapping](http://localhost:9200/twitter/tweet/_mapping)' -d '  
{  
"tweet" : {  
"properties" : {  
"message" : {"type" : "string", "store" : "yes"}  
}  
}  
}  
'

This throws the same error, after further investigation it seems this can be used after an initial command is sent to create the index first, like:

$ curl -XPUT '[http://localhost:9200/twitter/](http://localhost:9200/twitter/)'

Additionally, this can be bypassed by using the following syntax:

$ curl -XPUT '[http://localhost:9200/twitter/](http://localhost:9200/twitter/)' -d '  
{  
"mapping" : {  
"tweet" : {  
"properties" : {  
"message" : {"type" : "string", "store" : "yes"}  
}  
}  
}  
}

I'm not sure if this is purposeful but since it is still documented on the  
ES site I think it should be addressed or clarified.

Additional I can confirm that the mapping works correctly via the Java API  
using:

client.admin().indices().preparePutMapping(index).setType(type).setSource(mapping).execute().actionGet();

So this would suggest that the REST implementation is bugged. Any feedback  
or clarification would be greatly appreciated.

Cheers,

Jon

--  
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/f95d09af-c59a-4f66-a932-3ff0f6fabd41%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f95d09af-c59a-4f66-a932-3ff0f6fabd41%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:** ![karmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karmi/32/44951_2.png) [@karmi](https://discuss.elastic.co/u/karmi)\
**Post date:** [January 31, 2014, 6:11am UTC](https://discuss.elastic.co/t/-mapping-api-throws-indexmissingexception-even-with-examples-from-es-site/15494/2 "2014-01-31T06:11:10Z")

</div>

With the first command, you _update_ the mapping for an existing index --  
when that index doesn't exist, you'll get, predictably, an  
error: {"error":"IndexMissingException[[twitter] missing]","status":404}

With the second, command, you're creating an index called "twitter" (hence  
PUT with name, as per RESTful conventions), while also supplying additional  
configuration (mapping) for this index.

Karel

On Thursday, January 30, 2014 11:13:33 AM UTC+1, [pitty.t...@gmail.com](mailto:pitty.t...@gmail.com) wrote:

> Hi guys and gals,
> 
> I have come across a curious problem, possibly a bug while working with  
> mappings this morning. It's been a few months since I have had to create  
> any mapping but created series of PHP scripts to do so a few months ago.  
> Everything worked great until my latest upgrade to 0.90.10, now when I run  
> my scripts I get error 404 IndexMissingException. So I checked using the  
> mappings suggested in the ES documentation specifically:
> 
> $ curl -XPUT '[http://localhost:9200/twitter/tweet/\_mapping](http://localhost:9200/twitter/tweet/_mapping)' -d '  
> {  
> "tweet" : {  
> "properties" : {  
> "message" : {"type" : "string", "store" : "yes"}  
> }  
> }  
> }  
> '
> 
> This throws the same error, after further investigation it seems this can be used after an initial command is sent to create the index first, like:
> 
> $ curl -XPUT '[http://localhost:9200/twitter/](http://localhost:9200/twitter/)'
> 
> Additionally, this can be bypassed by using the following syntax:
> 
> $ curl -XPUT '[http://localhost:9200/twitter/](http://localhost:9200/twitter/)' -d '  
> {  
> "mapping" : {  
> "tweet" : {  
> "properties" : {  
> "message" : {"type" : "string", "store" : "yes"}  
> }  
> }  
> }  
> }
> 
> I'm not sure if this is purposeful but since it is still documented on the  
> ES site I think it should be addressed or clarified.
> 
> Additional I can confirm that the mapping works correctly via the Java API  
> using:
> 
> client.admin().indices().preparePutMapping(index).setType(type).setSource(mapping).execute().actionGet();
> 
> So this would suggest that the REST implementation is bugged. Any  
> feedback or clarification would be greatly appreciated.
> 
> Cheers,
> 
> Jon

--  
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/41899e23-948d-4cc2-b216-e40bda473331%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/41899e23-948d-4cc2-b216-e40bda473331%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:** ![pitty\_the\_fools](https://avatars.discourse-cdn.com/v4/letter/p/51bf81/32.png) [@pitty\_the\_fools](https://discuss.elastic.co/u/pitty_the_fools)\
**Post date:** [February 4, 2014, 12:41pm UTC](https://discuss.elastic.co/t/-mapping-api-throws-indexmissingexception-even-with-examples-from-es-site/15494/3 "2014-02-04T12:41:49Z")

</div>

Hi Karel,

Thanks for your response, OK just seems kind of counter intuative to me,  
after all I have supplied everything it would need to create the index,  
type and add the map (you know being elastic and all :-)) and it can easily  
be achieved via the Java API (I'm sure it used to be supported). The  
documentation should possibly mention its a limit to using the put mapping  
that the index must first be created, to avoid confusion.

Cheers,

Jon

On Friday, January 31, 2014 6:11:10 AM UTC, Karel Minařík wrote:

> With the first command, you _update_ the mapping for an existing index --  
> when that index doesn't exist, you'll get, predictably, an  
> error: {"error":"IndexMissingException[[twitter] missing]","status":404}
> 
> With the second, command, you're creating an index called "twitter" (hence  
> PUT with name, as per RESTful conventions), while also supplying additional  
> configuration (mapping) for this index.
> 
> Karel
> 
> On Thursday, January 30, 2014 11:13:33 AM UTC+1, pitty.t...@gmail.comwrote:
> 
> > Hi guys and gals,
> > 
> > I have come across a curious problem, possibly a bug while working with  
> > mappings this morning. It's been a few months since I have had to create  
> > any mapping but created series of PHP scripts to do so a few months ago.  
> > Everything worked great until my latest upgrade to 0.90.10, now when I run  
> > my scripts I get error 404 IndexMissingException. So I checked using the  
> > mappings suggested in the ES documentation specifically:
> > 
> > $ curl -XPUT '[http://localhost:9200/twitter/tweet/\_mapping](http://localhost:9200/twitter/tweet/_mapping)' -d '  
> > {  
> > "tweet" : {  
> > "properties" : {  
> > "message" : {"type" : "string", "store" : "yes"}  
> > }  
> > }  
> > }  
> > '
> > 
> > This throws the same error, after further investigation it seems this can be used after an initial command is sent to create the index first, like:
> > 
> > $ curl -XPUT '[http://localhost:9200/twitter/](http://localhost:9200/twitter/)'
> > 
> > Additionally, this can be bypassed by using the following syntax:
> > 
> > $ curl -XPUT '[http://localhost:9200/twitter/](http://localhost:9200/twitter/)' -d '  
> > {  
> > "mapping" : {  
> > "tweet" : {  
> > "properties" : {  
> > "message" : {"type" : "string", "store" : "yes"}  
> > }  
> > }  
> > }  
> > }
> > 
> > I'm not sure if this is purposeful but since it is still documented on  
> > the ES site I think it should be addressed or clarified.
> > 
> > Additional I can confirm that the mapping works correctly via the Java  
> > API using:
> > 
> > client.admin().indices().preparePutMapping(index).setType(type).setSource(mapping).execute().actionGet();
> > 
> > So this would suggest that the REST implementation is bugged. Any  
> > feedback or clarification would be greatly appreciated.
> > 
> > Cheers,
> > 
> > Jon

--  
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/2fb0bdc7-231b-4dfa-a333-6d9b853241f9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2fb0bdc7-231b-4dfa-a333-6d9b853241f9%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:** ![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:52am UTC](https://discuss.elastic.co/t/-mapping-api-throws-indexmissingexception-even-with-examples-from-es-site/15494/4 "2017-07-06T01:52:43Z")

</div>


