# Opinion needed about Document design for recursive sub-objects/documents

**URL:** <https://discuss.elastic.co/t/opinion-needed-about-document-design-for-recursive-sub-objects-documents/13798>\
**Category:** Elasticsearch\
**Created:** [September 29, 2013, 7:09pm UTC](https://discuss.elastic.co/t/opinion-needed-about-document-design-for-recursive-sub-objects-documents/13798 "2013-09-29T19:09:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [September 29, 2013, 7:09pm UTC](https://discuss.elastic.co/t/opinion-needed-about-document-design-for-recursive-sub-objects-documents/13798/1 "2013-09-29T19:09:54Z")

</div>

Hello,  
I am approaching document design to ease the process on Elasticsearch.

I am using ES to extract stats from ES. The frontend is the well known  
Kibana.  
The main difference between the typical setup is:

- I have almost 30M of lines each hour
- I need to search not only for all log lines containing a value or  
matching a query, but all the "consequent" lines
  - E.g.: I search for a request containing a specific payload; I want  
to produce a facet not only on those lines, but also on lines generated by  
a request needed by the "master" one

My idea is to create a document tree:

- SERVICE A Y
  - SERVICE B Y
    - SERVICE C Y
    - SERVICE D N
      - SERVICE E Y
      - SERVICE F Y
        - SERVICE G N

As result, I would like to be able to search for SERVICE D and get, without  
generating any other query:

- SERVICE D N
  - SERVICE E Y
  - SERVICE F Y
    - SERVICE G N

And be able to perform a facet on them:

- Matched 4
- Facet
  - Y 2
  - N 2

First attept, _CHILD MAPPING_.

Document structure:  
{  
"gcx": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",  
"oid": "LON6X0100",  
"sap": "1ASAP",  
"chld": [  
{  
"trxnb": "44",  
"t": "2013/09/28 11:39:01.123456",  
"sn": "PT\*",  
"st": "C",  
"app": "ROC",  
"be": "RI",  
"d": "OBE",  
"chld": [  
{  
"trxnb": "44-1",  
"t": "2013/09/28 11:39:01.223456",  
"sn": "PT\*",  
"st": "C",  
"app": "CPL",  
"be": "PI",  
"d": "OBE",  
"chld": [  
{  
"trxnb": "44-1-1",  
"t": "2013/09/28 11:39:01.323456",  
"sn": "PT\*",  
"st": "C",  
"app": "CPL",  
"be": "ACU",  
"d": "OBE",  
"chld": [  
{  
"trxnb": "44-1-1-1",  
"t": "2013/09/28 11:39:01.423456",  
"sn": "PEAUDQ",  
"st": "E",  
"app": "ELT",  
"be": "MPP",  
"d": "OBE",  
"chld": [  
{  
"trxnb": "44-1-1-1-1",  
"t": "2013/09/28 11:39:01.523456",  
"sn": "PNRADD",  
"st": "E",  
"app": "ROC",  
"be": "DI",  
"d": "TPF",  
"chld": [

```
                  ]
                },
                {
                  "trxnb": "44-1-1-1-2",
                  "t": "2013/09/28 11:39:01.623456",
                  "sn": "TFOPCQ",
                  "st": "E",
                  "app": "FOP",
                  "be": "FPP",
                  "d": "OBE",
                  "chld": [
                    
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

```

]  
}  
Mapping  
{  
"template": "aggregate\_index\*",  
"mappings": {  
"_default_" : {  
"dynamic\_templates": [  
{  
"chld\_template" : {  
"mapping": { "type": "nested" },  
"path\_match": "\*.chld"  
}  
}  
]  
}  
}  
}

Nested queries fail due to some parsing issue. Furthermore, they are  
designed to return the parent object.

Attempt 2, _PARENT-CHILD_ mapping:  
{  
"template": "aggregate\_index\*",  
"mappings": {  
"aggregate": {  
"\_parent": {  
"type": "aggregate"  
},  
"\_routing": {  
"required": true  
}  
}  
}  
}

I am unable to index, since the parent is the object itself and it is  
recursive.

Any advice?

I need to implement my custom query and add it to ES?

Best regards,  
Luca

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [September 30, 2013, 7:19am UTC](https://discuss.elastic.co/t/opinion-needed-about-document-design-for-recursive-sub-objects-documents/13798/2 "2013-09-30T07:19:55Z")

</div>

What parsing error did occur when you were using nested? Can you also check  
the mapping of the nested object fields are actually created based on your  
dynamic template? I think there is no need to use path match, match=chld\*  
should be sufficient.

On 29 September 2013 21:09, Luca Belluccini [lucabelluccini@gmail.com](mailto:lucabelluccini@gmail.com)wrote:

> Hello,  
> I am approaching document design to ease the process on Elasticsearch.
> 
> I am using ES to extract stats from ES. The frontend is the well known  
> Kibana.  
> The main difference between the typical setup is:
> 
> - I have almost 30M of lines each hour
> - I need to search not only for all log lines containing a value or  
> matching a query, but all the "consequent" lines
> - E.g.: I search for a request containing a specific payload; I  
> want to produce a facet not only on those lines, but also on lines  
> generated by a request needed by the "master" one
> 
> My idea is to create a document tree:
> 
> - SERVICE A Y
> - SERVICE B Y
> - SERVICE C Y
> - SERVICE D N
> - SERVICE E Y
> - SERVICE F Y
> - SERVICE G N
> 
> As result, I would like to be able to search for SERVICE D and get,  
> without generating any other query:
> 
> - SERVICE D N
> - SERVICE E Y
> - SERVICE F Y
> - SERVICE G N
> 
> And be able to perform a facet on them:
> 
> - Matched 4
> - Facet
> - Y 2
> - N 2
> 
> First attept, _CHILD MAPPING_.
> 
> Document structure:  
> {  
> "gcx": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",  
> "oid": "LON6X0100",  
> "sap": "1ASAP",  
> "chld": [  
> {  
> "trxnb": "44",  
> "t": "2013/09/28 11:39:01.123456",  
> "sn": "PT\*",  
> "st": "C",  
> "app": "ROC",  
> "be": "RI",  
> "d": "OBE",  
> "chld": [  
> {  
> "trxnb": "44-1",  
> "t": "2013/09/28 11:39:01.223456",  
> "sn": "PT\*",  
> "st": "C",  
> "app": "CPL",  
> "be": "PI",  
> "d": "OBE",  
> "chld": [  
> {  
> "trxnb": "44-1-1",  
> "t": "2013/09/28 11:39:01.323456",  
> "sn": "PT\*",  
> "st": "C",  
> "app": "CPL",  
> "be": "ACU",  
> "d": "OBE",  
> "chld": [  
> {  
> "trxnb": "44-1-1-1",  
> "t": "2013/09/28 11:39:01.423456",  
> "sn": "PEAUDQ",  
> "st": "E",  
> "app": "ELT",  
> "be": "MPP",  
> "d": "OBE",  
> "chld": [  
> {  
> "trxnb": "44-1-1-1-1",  
> "t": "2013/09/28 11:39:01.523456",  
> "sn": "PNRADD",  
> "st": "E",  
> "app": "ROC",  
> "be": "DI",  
> "d": "TPF",  
> "chld": [
> 
> ```
> ]
> },
> {
> "trxnb": "44-1-1-1-2",
> "t": "2013/09/28 11:39:01.623456",
> "sn": "TFOPCQ",
> "st": "E",
> "app": "FOP",
> "be": "FPP",
> "d": "OBE",
> "chld": [
> 
> ]
> }
> ]
> }
> ]
> }
> ]
> }
> ]
> }
> 
> ```
> 
> ]  
> }  
> Mapping  
> {  
> "template": "aggregate\_index\*",  
> "mappings": {  
> "_default_" : {  
> "dynamic\_templates": [  
> {  
> "chld\_template" : {  
> "mapping": { "type": "nested" },  
> "path\_match": "\*.chld"  
> }  
> }  
> ]  
> }  
> }  
> }
> 
> Nested queries fail due to some parsing issue. Furthermore, they are  
> designed to return the parent object.
> 
> Attempt 2, _PARENT-CHILD_ mapping:  
> {  
> "template": "aggregate\_index\*",  
> "mappings": {  
> "aggregate": {  
> "\_parent": {  
> "type": "aggregate"  
> },  
> "\_routing": {  
> "required": true  
> }  
> }  
> }  
> }
> 
> I am unable to index, since the parent is the object itself and it is  
> recursive.
> 
> Any advice?
> 
> I need to implement my custom query and add it to ES?
> 
> Best regards,  
> Luca
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Met vriendelijke groet,

Martijn van Groningen

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [September 30, 2013, 8:55am UTC](https://discuss.elastic.co/t/opinion-needed-about-document-design-for-recursive-sub-objects-documents/13798/3 "2013-09-30T08:55:16Z")

</div>

Using above example, you'll have no way to get data.  
I tried to change the data model:

curl -XPUT [http://NCE00259:9200/\_template/aggregate\_template](http://NCE00259:9200/_template/aggregate_template) -d'  
{  
"template": "aggregate\_index\*",  
"mappings": {  
"aggregate": {  
"properties" : {  
"chld" : {  
"type" : "nested",  
"include\_in\_parent" : false  
}  
}  
}  
}  
}  
'

curl -XPOST [http://NCE00259:9200/aggregate\_index/aggregate](http://NCE00259:9200/aggregate_index/aggregate) -d'  
{  
"gcx": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",  
"oid": "LON6X0100",  
"sap": "1ASAP",  
"chld": [  
{  
"trxnb": "44",  
"t": "2013/09/28 11:39:01.123456",  
"sn": "PT\*",  
"st": "C",  
"app": "ROC",  
"be": "RI",  
"d": "OBE"  
},  
{  
"trxnb": "44-1",  
"t": "2013/09/28 11:39:01.223456",  
"sn": "PT\*",  
"st": "C",  
"app": "CPL",  
"be": "PI",  
"d": "OBE"  
},  
{  
"trxnb": "44-1-1",  
"t": "2013/09/28 11:39:01.323456",  
"sn": "PT\*",  
"st": "C",  
"app": "CPL",  
"be": "ACU",  
"d": "OBE"  
},  
{  
"trxnb": "44-1-1-1",  
"t": "2013/09/28 11:39:01.423456",  
"sn": "PEAUDQ",  
"st": "E",  
"app": "ELT",  
"be": "MPP",  
"d": "OBE"  
},  
{  
"trxnb": "44-1-1-1-1",  
"t": "2013/09/28 11:39:01.523456",  
"sn": "PNRADD",  
"st": "E",  
"app": "ROC",  
"be": "DI",  
"d": "TPF"  
},  
{  
"trxnb": "44-1-1-1-2",  
"t": "2013/09/28 11:39:01.623456",  
"sn": "TFOPCQ",  
"st": "E",  
"app": "FOP",  
"be": "FPP",  
"d": "OBE"  
}  
]  
}  
'

But this kind of setup returns the whole document, not the chld document.

Il giorno lunedì 30 settembre 2013 09:19:55 UTC+2, Martijn v Groningen ha  
scritto:

> What parsing error did occur when you were using nested? Can you also  
> check the mapping of the nested object fields are actually created based on  
> your dynamic template? I think there is no need to use path match,  
> match=chld\* should be sufficient.
> 
> On 29 September 2013 21:09, Luca Belluccini \<[lucabel...@gmail.com](mailto:lucabel...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hello,  
> > I am approaching document design to ease the process on Elasticsearch.
> > 
> > I am using ES to extract stats from ES. The frontend is the well known  
> > Kibana.  
> > The main difference between the typical setup is:
> > 
> > - I have almost 30M of lines each hour
> > - I need to search not only for all log lines containing a value or  
> > matching a query, but all the "consequent" lines
> > - E.g.: I search for a request containing a specific payload; I  
> > want to produce a facet not only on those lines, but also on lines  
> > generated by a request needed by the "master" one
> > 
> > My idea is to create a document tree:
> > 
> > - SERVICE A Y
> > - SERVICE B Y
> > - SERVICE C Y
> > - SERVICE D N
> > - SERVICE E Y
> > - SERVICE F Y
> > - SERVICE G N
> > 
> > As result, I would like to be able to search for SERVICE D and get,  
> > without generating any other query:
> > 
> > - SERVICE D N
> > - SERVICE E Y
> > - SERVICE F Y
> > - SERVICE G N
> > 
> > And be able to perform a facet on them:
> > 
> > - Matched 4
> > - Facet
> > - Y 2
> > - N 2
> > 
> > First attept, _CHILD MAPPING_.
> > 
> > Document structure:  
> > {  
> > "gcx": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",  
> > "oid": "LON6X0100",  
> > "sap": "1ASAP",  
> > "chld": [  
> > {  
> > "trxnb": "44",  
> > "t": "2013/09/28 11:39:01.123456",  
> > "sn": "PT\*",  
> > "st": "C",  
> > "app": "ROC",  
> > "be": "RI",  
> > "d": "OBE",  
> > "chld": [  
> > {  
> > "trxnb": "44-1",  
> > "t": "2013/09/28 11:39:01.223456",  
> > "sn": "PT\*",  
> > "st": "C",  
> > "app": "CPL",  
> > "be": "PI",  
> > "d": "OBE",  
> > "chld": [  
> > {  
> > "trxnb": "44-1-1",  
> > "t": "2013/09/28 11:39:01.323456",  
> > "sn": "PT\*",  
> > "st": "C",  
> > "app": "CPL",  
> > "be": "ACU",  
> > "d": "OBE",  
> > "chld": [  
> > {  
> > "trxnb": "44-1-1-1",  
> > "t": "2013/09/28 11:39:01.423456",  
> > "sn": "PEAUDQ",  
> > "st": "E",  
> > "app": "ELT",  
> > "be": "MPP",  
> > "d": "OBE",  
> > "chld": [  
> > {  
> > "trxnb": "44-1-1-1-1",  
> > "t": "2013/09/28 11:39:01.523456",  
> > "sn": "PNRADD",  
> > "st": "E",  
> > "app": "ROC",  
> > "be": "DI",  
> > "d": "TPF",  
> > "chld": [
> > 
> > ```
> > ]
> > },
> > {
> > "trxnb": "44-1-1-1-2",
> > "t": "2013/09/28 11:39:01.623456",
> > "sn": "TFOPCQ",
> > "st": "E",
> > "app": "FOP",
> > "be": "FPP",
> > "d": "OBE",
> > "chld": [
> >                     
> > ]
> > }
> > ]
> > }
> > ]
> > }
> > ]
> > }
> > ]
> > }
> > 
> > ```
> > 
> > ]  
> > }  
> > Mapping  
> > {  
> > "template": "aggregate\_index\*",  
> > "mappings": {  
> > "_default_" : {  
> > "dynamic\_templates": [  
> > {  
> > "chld\_template" : {  
> > "mapping": { "type": "nested" },  
> > "path\_match": "\*.chld"  
> > }  
> > }  
> > ]  
> > }  
> > }  
> > }
> > 
> > Nested queries fail due to some parsing issue. Furthermore, they are  
> > designed to return the parent object.
> > 
> > Attempt 2, _PARENT-CHILD_ mapping:  
> > {  
> > "template": "aggregate\_index\*",  
> > "mappings": {  
> > "aggregate": {  
> > "\_parent": {  
> > "type": "aggregate"  
> > },  
> > "\_routing": {  
> > "required": true  
> > }  
> > }  
> > }  
> > }
> > 
> > I am unable to index, since the parent is the object itself and it is  
> > recursive.
> > 
> > Any advice?
> > 
> > I need to implement my custom query and add it to ES?
> > 
> > Best regards,  
> > Luca
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> Met vriendelijke groet,
> 
> Martijn van Groningen

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [September 30, 2013, 11:48am UTC](https://discuss.elastic.co/t/opinion-needed-about-document-design-for-recursive-sub-objects-documents/13798/4 "2013-09-30T11:48:11Z")

</div>

Yes, with the nested type and query, you only get back the complete doc and  
not the individual inner objects.

In that I would look into the using the \_parent field instead. So index  
each `chld` inner object as a single child document and index the rest of  
the document as parent document. You mentioned in your first email that you  
were unable to index because of recursiveness. Can you elaborate a bit more  
on that? I see that you have a hierarchy, but this doesn't have to be an  
issue.

On 30 September 2013 10:55, Luca Belluccini [lucabelluccini@gmail.com](mailto:lucabelluccini@gmail.com)wrote:

> Using above example, you'll have no way to get data.  
> I tried to change the data model:
> 
> curl -XPUT [http://NCE00259:9200/\_template/aggregate\_template](http://NCE00259:9200/_template/aggregate_template) -d'
> 
> {  
> "template": "aggregate\_index\*",  
> "mappings": {  
> "aggregate": {
> 
> ```
> "properties" : {
> 
> ```
> 
> "chld" : {  
> "type" : "nested",  
> "include\_in\_parent" : false  
> }  
> }  
> }  
> }  
> }  
> '
> 
> curl -XPOST [http://NCE00259:9200/aggregate\_index/aggregate](http://NCE00259:9200/aggregate_index/aggregate) -d'
> 
> {  
> "gcx": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",  
> "oid": "LON6X0100",  
> "sap": "1ASAP",  
> "chld": [  
> {  
> "trxnb": "44",  
> "t": "2013/09/28 11:39:01.123456",  
> "sn": "PT\*",  
> "st": "C",  
> "app": "ROC",  
> "be": "RI",  
> "d": "OBE"  
> },
> 
> ```
> {
> "trxnb": "44-1",
> "t": "2013/09/28 11:39:01.223456",
> "sn": "PT*",
> "st": "C",
> "app": "CPL",
> "be": "PI",
> "d": "OBE"
> },
> 
> {
> "trxnb": "44-1-1",
> "t": "2013/09/28 11:39:01.323456",
> "sn": "PT*",
> "st": "C",
> "app": "CPL",
> "be": "ACU",
> "d": "OBE"
> },
> 
> {
> "trxnb": "44-1-1-1",
> "t": "2013/09/28 11:39:01.423456",
> "sn": "PEAUDQ",
> "st": "E",
> "app": "ELT",
> "be": "MPP",
> "d": "OBE"
> },
> 
> {
> "trxnb": "44-1-1-1-1",
> "t": "2013/09/28 11:39:01.523456",
> "sn": "PNRADD",
> "st": "E",
> "app": "ROC",
> "be": "DI",
> "d": "TPF"
> },
> 
> {
> "trxnb": "44-1-1-1-2",
> "t": "2013/09/28 11:39:01.623456",
> "sn": "TFOPCQ",
> "st": "E",
> "app": "FOP",
> "be": "FPP",
> "d": "OBE"
> }
> 
> ```
> 
> ]  
> }  
> '
> 
> But this kind of setup returns the whole document, not the chld document.
> 
> Il giorno lunedì 30 settembre 2013 09:19:55 UTC+2, Martijn v Groningen ha  
> scritto:
> 
> > What parsing error did occur when you were using nested? Can you also  
> > check the mapping of the nested object fields are actually created based on  
> > your dynamic template? I think there is no need to use path match,  
> > match=chld\* should be sufficient.
> > 
> > On 29 September 2013 21:09, Luca Belluccini [lucabel...@gmail.com](mailto:lucabel...@gmail.com) wrote:
> > 
> > > Hello,  
> > > I am approaching document design to ease the process on Elasticsearch.
> > > 
> > > I am using ES to extract stats from ES. The frontend is the well known  
> > > Kibana.  
> > > The main difference between the typical setup is:
> > > 
> > > - I have almost 30M of lines each hour
> > > - I need to search not only for all log lines containing a value or  
> > > matching a query, but all the "consequent" lines
> > > - E.g.: I search for a request containing a specific payload; I  
> > > want to produce a facet not only on those lines, but also on lines  
> > > generated by a request needed by the "master" one
> > > 
> > > My idea is to create a document tree:
> > > 
> > > - SERVICE A Y
> > > - SERVICE B Y
> > > - SERVICE C Y
> > > - SERVICE D N
> > > - SERVICE E Y
> > > - SERVICE F Y
> > > - SERVICE G N
> > > 
> > > As result, I would like to be able to search for SERVICE D and get,  
> > > without generating any other query:
> > > 
> > > - SERVICE D N
> > > - SERVICE E Y
> > > - SERVICE F Y
> > > - SERVICE G N
> > > 
> > > And be able to perform a facet on them:
> > > 
> > > - Matched 4
> > > - Facet
> > > - Y 2
> > > - N 2
> > > 
> > > First attept, _CHILD MAPPING_.
> > > 
> > > Document structure:  
> > > {  
> > > "gcx": " **XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX**",  
> > > "oid": "LON6X0100",  
> > > "sap": "1ASAP",  
> > > "chld": [  
> > > {  
> > > "trxnb": "44",  
> > > "t": "2013/09/28 11:39:01.123456",  
> > > "sn": "PT\*",  
> > > "st": "C",  
> > > "app": "ROC",  
> > > "be": "RI",  
> > > "d": "OBE",  
> > > "chld": [  
> > > {  
> > > "trxnb": "44-1",  
> > > "t": "2013/09/28 11:39:01.223456",  
> > > "sn": "PT\*",  
> > > "st": "C",  
> > > "app": "CPL",  
> > > "be": "PI",  
> > > "d": "OBE",  
> > > "chld": [  
> > > {  
> > > "trxnb": "44-1-1",  
> > > "t": "2013/09/28 11:39:01.323456",  
> > > "sn": "PT\*",  
> > > "st": "C",  
> > > "app": "CPL",  
> > > "be": "ACU",  
> > > "d": "OBE",  
> > > "chld": [  
> > > {  
> > > "trxnb": "44-1-1-1",  
> > > "t": "2013/09/28 11:39:01.423456",  
> > > "sn": "PEAUDQ",  
> > > "st": "E",  
> > > "app": "ELT",  
> > > "be": "MPP",  
> > > "d": "OBE",  
> > > "chld": [  
> > > {  
> > > "trxnb": "44-1-1-1-1",  
> > > "t": "2013/09/28 11:39:01.523456",  
> > > "sn": "PNRADD",  
> > > "st": "E",  
> > > "app": "ROC",  
> > > "be": "DI",  
> > > "d": "TPF",  
> > > "chld": [
> > > 
> > > ```
> > > ]
> > > },
> > > {
> > > "trxnb": "44-1-1-1-2",
> > > "t": "2013/09/28 11:39:01.623456",
> > > "sn": "TFOPCQ",
> > > "st": "E",
> > > "app": "FOP",
> > > "be": "FPP",
> > > "d": "OBE",
> > > "chld": [
> > > 
> > > ]
> > > }
> > > ]
> > > }
> > > ]
> > > }
> > > ]
> > > }
> > > ]
> > > }
> > > 
> > > ```
> > > 
> > > ]  
> > > }  
> > > Mapping  
> > > {  
> > > "template": "aggregate\_index\*",  
> > > "mappings": {  
> > > "_default_" : {  
> > > "dynamic\_templates": [  
> > > {  
> > > "chld\_template" : {  
> > > "mapping": { "type": "nested" },  
> > > "path\_match": "\*.chld"  
> > > }  
> > > }  
> > > ]  
> > > }  
> > > }  
> > > }
> > > 
> > > Nested queries fail due to some parsing issue. Furthermore, they are  
> > > designed to return the parent object.
> > > 
> > > Attempt 2, _PARENT-CHILD_ mapping:  
> > > {  
> > > "template": "aggregate\_index\*",  
> > > "mappings": {  
> > > "aggregate": {  
> > > "\_parent": {  
> > > "type": "aggregate"  
> > > },  
> > > "\_routing": {  
> > > "required": true  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > I am unable to index, since the parent is the object itself and it is  
> > > recursive.
> > > 
> > > Any advice?
> > > 
> > > I need to implement my custom query and add it to ES?
> > > 
> > > Best regards,  
> > > Luca
> > > 
> > > --  
> > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > Met vriendelijke groet,
> > 
> > Martijn van Groningen

--  
Met vriendelijke groet,

Martijn van Groningen

--  
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).  
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, 2:14am UTC](https://discuss.elastic.co/t/opinion-needed-about-document-design-for-recursive-sub-objects-documents/13798/5 "2017-07-06T02:14:15Z")

</div>


