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

**URL:** <https://discuss.elastic.co/t/nested-object-under-path-messages-is-not-of-nested-type/23014>\
**Category:** Elasticsearch\
**Created:** [March 31, 2015, 4:06pm UTC](https://discuss.elastic.co/t/nested-object-under-path-messages-is-not-of-nested-type/23014 "2015-03-31T16:06:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![djbuckle91](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/djbuckle91/32/795_2.png) [@djbuckle91](https://discuss.elastic.co/u/djbuckle91)\
**Post date:** [March 31, 2015, 4:06pm UTC](https://discuss.elastic.co/t/nested-object-under-path-messages-is-not-of-nested-type/23014/1 "2015-03-31T16:06:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![masaru](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@masaru](https://discuss.elastic.co/u/masaru)\
**Post date:** [April 1, 2015, 1:41am UTC](https://discuss.elastic.co/t/nested-object-under-path-messages-is-not-of-nested-type/23014/2 "2015-04-01T01:41:56Z")

</div>

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](mailto: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](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](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](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](mailto: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](https://groups.google.com/d/msgid/elasticsearch/9c1395b9-99aa-47e8-900b-a819323275ea%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](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](mailto: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](https://groups.google.com/d/msgid/elasticsearch/etPan.551b4d21.74b0dc51.3b55%40citra-2.local).  
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:22am UTC](https://discuss.elastic.co/t/nested-object-under-path-messages-is-not-of-nested-type/23014/3 "2017-07-06T00:22:32Z")

</div>


