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

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",
"Gender" : "http://www.xyz.com/ontology/Gender/Female"
}, {
"@id" : "http://www.abc.com/1234567890",
"PostId" : "http://www.abc.com/1234567890_542839079235084"
}, {
"@id" : "http://www.abc.com/1234567890_542839079235084",
"Language" : "http://www.xyz.com/ontology/Language/English ",
"http://www.xyz.com/OWL/abc#CategoryName" : "Real Estate"
} ],
"@context" : {
"Gender" : {
"@id" : "http://www.xyz.com/ontology#Gender",
"@type" : "@id"
},
"CategoryName" : {
"@id" : "http://www.xyz.com/OWL/abc#CategoryName",
"@type" : "http://www.w3.org/2001/XMLSchema#string"
},
"PostDetails" : {
"@id" : "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" : {
"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" : {
"terms" : {
"field" : "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",
"Gender" : "http://www.xyz.com/ontology/Gender/Female"
}, {
"@id" : "http://www.abc.com/1234567890",
"PageId" : "1234567890",
"PostDetails" : "http://www.abc.com/1234567890_542839079235084",
"PostId" : "http://www.abc.com/1234567890_542839079235084"
}, {
"@id" : "http://www.abc.com/1234567890_542839079235084",
"Language" : "http://www.xyz.com/ontology/Language/English ",
"dbp" : [ "http://dbpedia.org/resource/Hypertext_Transfer_Protocol", "http://dbpedia.org/resource/Health_care" ],
"http://www.xyz.com/OWL/abc#CategoryName" : "Real Estate"
} ],
"@context" : {
"Gender" : {
"@id" : "http://www.xyz.com/ontology#Gender",
"@type" : "@id"
},
"CategoryName" : {
"@id" : "http://www.xyz.com/OWL/abc#CategoryName",
"@type" : "http://www.w3.org/2001/XMLSchema#string"
},
"dbp" : {
"@id" : "http://www.xyz.com/ontology#dbp",
"@type" : "@id"
},
"PostDetails" : {
"@id" : "http://www.xyz.com/OWL/abc#PostDetails",
"@type" : "@id"
},
"PageId" : "http://www.xyz.com/OWL/abc#PageId"
}
}
} ]
},
"aggregations" : {
"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" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"Key" : "Real Estate",
"doc_count" : 1
} ]
}
}
}

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

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

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

..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 ?

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

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

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" : {
"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