# Recursivity in ES structure

**URL:** <https://discuss.elastic.co/t/recursivity-in-es-structure/145320>\
**Category:** Elasticsearch\
**Created:** [August 21, 2018, 8:00am UTC](https://discuss.elastic.co/t/recursivity-in-es-structure/145320 "2018-08-21T08:00:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave38](https://avatars.discourse-cdn.com/v4/letter/d/6f9a4e/32.png) [@Dave38](https://discuss.elastic.co/u/Dave38)\
**Post date:** [August 21, 2018, 8:00am UTC](https://discuss.elastic.co/t/recursivity-in-es-structure/145320/1 "2018-08-21T08:00:10Z")

</div>

Hi everyone !

I have a question about es structure and complex objects.  
I need to create a complex structure with recursive objects. So I have defined a first object, for example "message", and inside message i put the reference : "$ref": "#/definitions/message" (a message can contain an other message).  
It works when I parse my structure in an JSON parser, but I received a 400 error when I try to create my structure....  
So first of all, is it possible to create a recursive object in ES structure? And if yes, how can i do that?  
Thank you !!!!

David

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 21, 2018, 8:01am UTC](https://discuss.elastic.co/t/recursivity-in-es-structure/145320/2 "2018-08-21T08:01:26Z")

</div>

> [@Dave38](#):
>
> It works when I parse my structure in an JSON parser, but I received a 400 error when I try to create my structure....

It'd help if you shared the error 🙂

---

<div class="post-metadata">

**Author:** ![Dave38](https://avatars.discourse-cdn.com/v4/letter/d/6f9a4e/32.png) [@Dave38](https://discuss.elastic.co/u/Dave38)\
**Post date:** [August 21, 2018, 10:10am UTC](https://discuss.elastic.co/t/recursivity-in-es-structure/145320/4 "2018-08-21T10:10:49Z")

</div>

just to contextualise the situation, my structure is construct like this :

{  
"definitions" : {  
"message" : {  
"properties": {  
...   
}   
},  
"conversation" : {  
"properties" : {

```
						"$ref": "#/definitions/message",
						...                				
				}
	}
},

"settings" : {
	"number_of_shards" : 1
},
  "mappings": {
     "BODY": {
        "properties": {
          	"$ref": "#/definitions/conversation"                	
        }
     }
}

```

}

and i've got this error :  
{  
"error": {  
"root\_cause": [  
{  
"type": "mapper\_parsing\_exception",  
"reason": "Expected map for property [fields] on field [$ref] but got a class java.lang.String"  
}  
],  
"type": "mapper\_parsing\_exception",  
"reason": "Failed to parse mapping [BODY]: Expected map for property [fields] on field [$ref] but got a class java.lang.String",  
"caused\_by": {  
"type": "mapper\_parsing\_exception",  
"reason": "Expected map for property [fields] on field [$ref] but got a class java.lang.String"  
}  
},  
"status": 400  
}

---

<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:** [September 18, 2018, 10:10am UTC](https://discuss.elastic.co/t/recursivity-in-es-structure/145320/5 "2018-09-18T10:10:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
