Nested object under path [messages] is not of nested type

I am having a lot of issues with the nested type mapping in Elasticsearch,
I have ran this to create my index:

curl -XPOST 'http://localhost:9200/thread_and_messages' -d
'{"mappings" : {
"message": {
"properties": {
"messages": {
"type": "nested",
"include_in_parent": true,
"properties": {
"message_id": {"type": "string"},
"message_text": {"type": "string"},
"message_nick": {"type": "string"}
}
}
}
}
}}'

Then this is how I've indexed a document:

curl -XPUT 'http://localhost:9200/thread_and_messages/thread/1' -d
'{
"thread_id":"2",
"thread_name":"Windows",
"created":"Wed Mar 25 2015",
"first_nick":"Admin",
"messages":[
{"message_id":"5", "message_text":" Pc with a mouse", "message_nick":"Admin"},
{"message_id":"6", "message_text":"Keyboard", "message_nick":"Admin"},
{"message_id":"7", "message_text":"iPhone", "message_nick":"Admin"},
{"message_id":"8", "message_text":"Gym", "message_nick":"Admin"}]"
}'

This is my query:

curl -XGET 'http://localhost:9200/thread_and_messages/thread/_search' -d
'{"query": {
"bool": {
"must": [
{"match": {"thread_name": "windows"}},
{"nested": {
"path": "messages", "query": {
"bool": {
"must": [{
"match": {"messages.message_text": "gym"}
}]
}
}
}}
]}
}
}'

I am receiving this error, even though I have clearly mapped messages as a
nested type:

QueryParsingException[[thread_and_messages] [nested]
nested object under path [messages] is not of nested type

--
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/9c1395b9-99aa-47e8-900b-a819323275ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi,

You put mapping of "message" type while you query on "thread" type.
Since "thread" type isn't defined, you get the error.

Masaru

On April 1, 2015 at 01:06:51, Daniel Buckle (danielbuckle31@gmail.com) wrote:

I am having a lot of issues with the nested type mapping in Elasticsearch, I have ran this to create my index:

curl -XPOST 'http://localhost:9200/thread_and_messages' -d
'{"mappings" : {
"message": {
"properties": {
"messages": {
"type": "nested",
"include_in_parent": true,
"properties": {
"message_id": {"type": "string"},
"message_text": {"type": "string"},
"message_nick": {"type": "string"}
}
}
}
}
}}'

Then this is how I've indexed a document:

curl -XPUT 'http://localhost:9200/thread_and_messages/thread/1' -d
'{
"thread_id":"2",
"thread_name":"Windows",
"created":"Wed Mar 25 2015",
"first_nick":"Admin",
"messages":[
{"message_id":"5", "message_text":" Pc with a mouse", "message_nick":"Admin"},
{"message_id":"6", "message_text":"Keyboard", "message_nick":"Admin"},
{"message_id":"7", "message_text":"iPhone", "message_nick":"Admin"},
{"message_id":"8", "message_text":"Gym", "message_nick":"Admin"}]"
}'

This is my query:

curl -XGET 'http://localhost:9200/thread_and_messages/thread/_search' -d
'{"query": {
"bool": {
"must": [
{"match": {"thread_name": "windows"}},
{"nested": {
"path": "messages", "query": {
"bool": {
"must": [{
"match": {"messages.message_text": "gym"}
}]
}
}
}}
]}
}
}'

I am receiving this error, even though I have clearly mapped messages as a nested type:

QueryParsingException[[thread_and_messages] [nested]
nested object under path [messages] is not of nested type

--
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/9c1395b9-99aa-47e8-900b-a819323275ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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/etPan.551b4d21.74b0dc51.3b55%40citra-2.local.
For more options, visit https://groups.google.com/d/optout.