_mapping API throws IndexMissingException even with examples from ES site


(pitty.the.fools) #1

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' -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/'

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

$ curl -XPUT '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.
To view this discussion on the web visit 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.


(Karel Minarik) #2

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 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' -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/'

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

$ curl -XPUT '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.
To view this discussion on the web visit 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.


(pitty.the.fools) #3

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' -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/'

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

$ curl -XPUT '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.
To view this discussion on the web visit 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.


(system) #4