Groupby on dynamic fields

Hi

I have doc like below

doc1:

"url":{
"http://hello.com":10,
"http://hello2.com":20,
}

doc2:

"url":{
"http://hello3.com":10,
"http://hello2.com":20,
"http://hello4.com":10,
"http://hello6.com":20
}

I want to group by fields under url[in my case url is a nested field]

The result should be combined as below...

which actually matches the url and sum the count

doc1:

"url":{
"http://hello.com":10,
"http://hello2.com":40,
"http://hello3.com":10,
"http://hello4.com":10,
"http://hello6.com":20
}

Basically i dont know what are the fields present inside the url's...

Is there a way to get aggregation like this?

You are going to produce a lot of fields in the mapping and may be hit soon the default 1000 fields in mapping.

May be a key/value approach would be better?

It will then make that easier to build an aggregation on.

can you give me an example?

I had kept url as key and count as value...

Did you change the document form? Or still using initial structure?

If the later, I don’t know how you can do it. May be with this? https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping-field-names-field.html

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