Pie chart - Nested data - Same document - Wrong aggregation


(Shade Girl) #1

i would like to know how to generate a pie chart with the following data:

themes_subjects{
type:nested,
properties{
type:nested
theme{
type:string
},
subject{
type:string
}
}

example

document 1
theme1,subject1;
theme1,subject2;
theme2,subject1;
theme2,subject3;

But as I'm adding buckets and sub-buckets theme3 shouldn't become a theme1 sub-bucket, just because it's on the same document
I'm using version 2.3.3 of elasticsearch and kibana 4.5

thanks =D


(Tyler Smalley) #2

Lucene has no concept of inner objects, so Elasticsearch flattens object hierarchies into a simple list of field names and values.

your document:

[{ "theme": "theme1", "subject": "subject1" }, { "theme": "theme1", "subject": "subject2" }, { "theme": "theme2", "subject": "subject1" }, { "theme": "theme2", "subject": "subject3" }]

will be transformed internally into a document that looks more like this:

{ theme: ["theme1", "theme1", "theme2", "theme2"], subject: ["subject1", "subject2", "subject1", "subject3"] }

Hope this helps. It sounds like you will want to create separate documents for the nested them subjects.


(system) #3