# Not able to run aggregate(Facets) query for a nested JsonLD

**URL:** <https://discuss.elastic.co/t/not-able-to-run-aggregate-facets-query-for-a-nested-jsonld/59976>\
**Category:** Elasticsearch\
**Created:** [September 7, 2016, 12:06pm UTC](https://discuss.elastic.co/t/not-able-to-run-aggregate-facets-query-for-a-nested-jsonld/59976 "2016-09-07T12:06:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![SindhujaM](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@SindhujaM](https://discuss.elastic.co/u/SindhujaM)\
**Post date:** [September 7, 2016, 12:06pm UTC](https://discuss.elastic.co/t/not-able-to-run-aggregate-facets-query-for-a-nested-jsonld/59976/1 "2016-09-07T12:06:23Z")

</div>

**PROBLEM : Version : ElasticSearch 2.4.0**  
Not able to run aggregate(Facets) query for a nested JsonLD.  
Step 1 :Input JSonLD File  
{  
"@graph" : [ {  
"@id" : "[http://www.xyz.com/ontology/Person/estate](http://www.xyz.com/ontology/Person/estate)",  
"Gender" : "[http://www.xyz.com/ontology/Gender/Female](http://www.xyz.com/ontology/Gender/Female)"  
}, {  
"@id" : "[http://www.abc.com/1234567890](http://www.abc.com/1234567890)",  
"PostId" : "[http://www.abc.com/1234567890\_542839079235084](http://www.abc.com/1234567890_542839079235084)"  
}, {  
"@id" : "[http://www.abc.com/1234567890\_542839079235084](http://www.abc.com/1234567890_542839079235084)",  
"Language" : "[http://www.xyz.com/ontology/Language/English](http://www.xyz.com/ontology/Language/English) ",  
"[http://www.xyz.com/OWL/abc#CategoryName](http://www.xyz.com/OWL/abc#CategoryName)" : "Real Estate"  
} ],  
"@context" : {  
"Gender" : {  
"@id" : "[http://www.xyz.com/ontology#Gender](http://www.xyz.com/ontology#Gender)",  
"@type" : "@id"  
},  
"CategoryName" : {  
"@id" : "[http://www.xyz.com/OWL/abc#CategoryName](http://www.xyz.com/OWL/abc#CategoryName)",  
"@type" : "[http://www.w3.org/2001/XMLSchema#string](http://www.w3.org/2001/XMLSchema#string)"  
},  
"PostDetails" : {  
"@id" : "[http://www.xyz.com/OWL/abc#PostDetails](http://www.xyz.com/OWL/abc#PostDetails)",  
"@type" : "@id"  
}  
}  
}  
Step 2 :  
Mapping  
curl -XPOST localhost:9200/facettest -d '{  
"mappings": {  
"data": {  
"properties": {  
"[http://www.xyz.com/OWL/abc#CategoryName](http://www.xyz.com/OWL/abc#CategoryName)" : {  
"type": "string",  
"fields": {  
"raw" : {  
"type": "string",  
"index": "not\_analyzed"  
}  
}  
}  
}  
}  
}  
}'  
Response :  
{"acknowledged":true}

Step 3 :

Indexing into ElasticSearch

curl -XPOST localhost:9200/facettest/data/1 -d @/home/bigtapp/Downloads/estestjson.json

Response :

{"\_index":"facettest","\_type":"data","\_id":"1","\_version":1,"\_shards":{"total":2,"successful":1,"failed":0},"created":true}

Step 4 :

curl -XGET localhost:9200/facettest/data/\_search/?pretty=true -d '{  
"size" : 10,  
"aggs" : {  
"[http://www.xyz.com/OWL/abc#CategoryName](http://www.xyz.com/OWL/abc#CategoryName)" : {  
"terms" : {  
"field" : "[http://www.xyz.com/OWL/abc#CategoryName.raw](http://www.xyz.com/OWL/abc#CategoryName.raw)"  
}  
}  
}  
}'

Response :

{  
"took" : 8,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 1,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "facettest",  
"\_type" : "data",  
"\_id" : "1",  
"\_score" : 1.0,  
"\_source" : {  
"@graph" : [ {  
"@id" : "[http://www.xyz.com/ontology/Person/estate](http://www.xyz.com/ontology/Person/estate)",  
"Gender" : "[http://www.xyz.com/ontology/Gender/Female](http://www.xyz.com/ontology/Gender/Female)"  
}, {  
"@id" : "[http://www.abc.com/1234567890](http://www.abc.com/1234567890)",  
"PageId" : "1234567890",  
"PostDetails" : "[http://www.abc.com/1234567890\_542839079235084](http://www.abc.com/1234567890_542839079235084)",  
"PostId" : "[http://www.abc.com/1234567890\_542839079235084](http://www.abc.com/1234567890_542839079235084)"  
}, {  
"@id" : "[http://www.abc.com/1234567890\_542839079235084](http://www.abc.com/1234567890_542839079235084)",  
"Language" : "[http://www.xyz.com/ontology/Language/English](http://www.xyz.com/ontology/Language/English) ",  
"dbp" : ["[http://dbpedia.org/resource/Hypertext\_Transfer\_Protocol](http://dbpedia.org/resource/Hypertext_Transfer_Protocol)", "[http://dbpedia.org/resource/Health\_care](http://dbpedia.org/resource/Health_care)" ],  
"[http://www.xyz.com/OWL/abc#CategoryName](http://www.xyz.com/OWL/abc#CategoryName)" : "Real Estate"  
} ],  
"@context" : {  
"Gender" : {  
"@id" : "[http://www.xyz.com/ontology#Gender](http://www.xyz.com/ontology#Gender)",  
"@type" : "@id"  
},  
"CategoryName" : {  
"@id" : "[http://www.xyz.com/OWL/abc#CategoryName](http://www.xyz.com/OWL/abc#CategoryName)",  
"@type" : "[http://www.w3.org/2001/XMLSchema#string](http://www.w3.org/2001/XMLSchema#string)"  
},  
"dbp" : {  
"@id" : "[http://www.xyz.com/ontology#dbp](http://www.xyz.com/ontology#dbp)",  
"@type" : "@id"  
},  
"PostDetails" : {  
"@id" : "[http://www.xyz.com/OWL/abc#PostDetails](http://www.xyz.com/OWL/abc#PostDetails)",  
"@type" : "@id"  
},  
"PageId" : "[http://www.xyz.com/OWL/abc#PageId](http://www.xyz.com/OWL/abc#PageId)"  
}  
}  
} ]  
},  
"aggregations" : {  
"[http://www.xyz.com/OWL/abc#CategoryName](http://www.xyz.com/OWL/abc#CategoryName)" : {  
"doc\_count\_error\_upper\_bound" : 0,  
"sum\_other\_doc\_count" : 0,  
"buckets" : []  
}  
}  
}

* * *

Here, we dont get any aggregation for the CategoryName

* * *

Expected Result in Aggregation  
#####################################  
"aggregations" : {  
"[http://www.xyz.com/OWL/abc#CategoryName](http://www.xyz.com/OWL/abc#CategoryName)" : {  
"doc\_count\_error\_upper\_bound" : 0,  
"sum\_other\_doc\_count" : 0,  
"buckets" : [  
{  
"Key" : "Real Estate",  
"doc\_count" : 1  
} ]  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [September 8, 2016, 8:50am UTC](https://discuss.elastic.co/t/not-able-to-run-aggregate-facets-query-for-a-nested-jsonld/59976/2 "2016-09-08T08:50:12Z")

</div>

> [@SindhujaM](#):
>
> curl -XPOST localhost:9200/facettest -d '{ "mappings": { "data": { "properties": { "[http://www.xyz.com/OWL/abc#CategoryName](http://www.xyz.com/OWL/abc#CategoryName)" : { "type": "string", "fields": { "raw" : { "type": "string", "index": "not\_analyzed" } } } } } }}'

But doesn't this fail on 2.4 with this issue?

```
MapperParsingException[Field name [http://www.xyz.com/OWL/abc#CategoryName] cannot contain '.']

```

---

<div class="post-metadata">

**Author:** ![SindhujaM](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@SindhujaM](https://discuss.elastic.co/u/SindhujaM)\
**Post date:** [September 8, 2016, 1:09pm UTC](https://discuss.elastic.co/t/not-able-to-run-aggregate-facets-query-for-a-nested-jsonld/59976/3 "2016-09-08T13:09:15Z")

</div>

Hi Mark\_Harwood,

Please set this property in the environmental Variables

export ES\_JAVA\_OPTS="-Dmapper.allow\_dots\_in\_name=true"

then the field\_name containing dot (.) will not throw any errors

Thanks

Regards  
Sindhuja.M

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [September 8, 2016, 1:13pm UTC](https://discuss.elastic.co/t/not-able-to-run-aggregate-facets-query-for-a-nested-jsonld/59976/4 "2016-09-08T13:13:30Z")

</div>

> [@SindhujaM](#):
>
> then the field\_name containing dot (.) will not throw any errors

..perhaps not noisily at ingest time but instead failing silently at query time.

Note that part of the reason for disallowing dots in field names was to avoid the ambiguity in how aggregations like yours might refer to nested fields.

What happens if you remove the dots from the field names and attempt the same type of query ?

---

<div class="post-metadata">

**Author:** ![SindhujaM](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@SindhujaM](https://discuss.elastic.co/u/SindhujaM)\
**Post date:** [September 9, 2016, 6:26am UTC](https://discuss.elastic.co/t/not-able-to-run-aggregate-facets-query-for-a-nested-jsonld/59976/5 "2016-09-09T06:26:39Z")

</div>

Hi Mark,

On removing dots and applying the same process , I face the same issue.

Here also the **fails @ query time on aggregation.**

So, Kindly provide me a better solution to solve this.

Thanks in Advance

Regrads  
Sindhuja.M

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [September 9, 2016, 8:10am UTC](https://discuss.elastic.co/t/not-able-to-run-aggregate-facets-query-for-a-nested-jsonld/59976/6 "2016-09-09T08:10:04Z")

</div>

> [@SindhujaM](#):
>
> { "@graph" : [{ "@id" : "[http://www.xyz.com/ontology/Person/estate](http://www.xyz.com/ontology/Person/estate)", "Gender" : "[http://www.xyz.com/ontology/Gender/Female](http://www.xyz.com/ontology/Gender/Female)" }, { "@id" : "[http://www.abc.com/1234567890](http://www.abc.com/1234567890)", "PostId" : "[http://www.abc.com/1234567890\_542839079235084](http://www.abc.com/1234567890_542839079235084)" }, { "@id" : "[http://www.abc.com/1234567890\_542839079235084](http://www.abc.com/1234567890_542839079235084)", "Language" : "[http://www.xyz.com/ontology/Language/English](http://www.xyz.com/ontology/Language/English) ", "[http://www.xyz.com/OWL/abc#CategoryName](http://www.xyz.com/OWL/abc#CategoryName)" : "Real Estate" } ], "@context" : { "Gender" : { "@id" : "[http://www.xyz.com/ontology#Gender](http://www.xyz.com/ontology#Gender)", "@type" : "@id" }, "CategoryName" : { "@id" : "[http://www.xyz.com/OWL/abc#CategoryName](http://www.xyz.com/OWL/abc#CategoryName)", "@type" : "[http://www.w3.org/2001/XMLSchema#string](http://www.w3.org/2001/XMLSchema#string)" }, "PostDetails" : { "@id" : "[http://www.xyz.com/OWL/abc#PostDetails](http://www.xyz.com/OWL/abc#PostDetails)", "@type" : "@id" } }}

Can you reply with the smallest reproducible example that demonstrates the exact issue?

---

<div class="post-metadata">

**Author:** ![SindhujaM](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@SindhujaM](https://discuss.elastic.co/u/SindhujaM)\
**Post date:** [September 16, 2016, 6:34am UTC](https://discuss.elastic.co/t/not-able-to-run-aggregate-facets-query-for-a-nested-jsonld/59976/7 "2016-09-16T06:34:49Z")

</div>

hi

when I apply the aggregation query, i m not getting any values inside the buckets.. the array is empty..

My expected result should be  
{  
  
}  
"aggregations" : {  
"[http://www.xyz.com/OWL/abc#CategoryName](http://www.xyz.com/OWL/abc#CategoryName)" : {  
"doc\_count\_error\_upper\_bound" : 0,  
"sum\_other\_doc\_count" : 0,  
"buckets" : [  
{  
"Key" : "Real Estate",  
"doc\_count" : 1  
} ]  
}  
}

so, kindly help me to achieve this

---

<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 5, 2017, 10:19pm UTC](https://discuss.elastic.co/t/not-able-to-run-aggregate-facets-query-for-a-nested-jsonld/59976/8 "2017-07-05T22:19:47Z")

</div>


