Returning multiple values on aggregation

Hi,

I have an bulk aggregation and want to display a few of the fields not only
the key i'm splitting. The query is something like this :

{
"size": 0,
"fields" : ["title"],
"aggs": {
"group_by_authors": {
"terms": {
"script": "doc['author'].value"
},
"aggs":{
"get_by_local_id":{
"terms":{
"field":"local_id"
}
}
}
}
}
}

With the query above i'm able to split the docs according to the authors
and then on sub-aggregation i pull the document ids those people are
related to.
What i need is instead of getting only the ids (local_id) to get more
fields of document. I can use terms + script but again i have one value
back. Which is
something like :

{
"size": 0,
"fields" : ["title"],
"aggs": {
"group_by_authors": {
"terms": {
"script": "doc['authors.name'].value + '|' +
doc['authors.email'].value"
},
"aggs":{
"get_by_local_id":{
"terms":{
"field":"local_id",
"script":"doc['type'].value"
}
}
}
}
}
}

I can do some magic with script to get more values and then parse it in my
code but, it becomes very ugly. On docs it says it is possible to get
multiple
values back on aggregation. Any examples would be very useful.

Thanks in advance.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/06d8e351-52af-4f1d-a1d2-80f789327315%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Would the top_hits aggregation help you here? It allows you to display the
top N documents which fall into a particular bucket in the aggregations.

Colin

On Tuesday, 13 January 2015 22:24:18 UTC, makkalot wrote:

Hi,

I have an bulk aggregation and want to display a few of the fields not
only the key i'm splitting. The query is something like this :

{
"size": 0,
"fields" : ["title"],
"aggs": {
"group_by_authors": {
"terms": {
"script": "doc['author'].value"
},
"aggs":{
"get_by_local_id":{
"terms":{
"field":"local_id"
}
}
}
}
}
}

With the query above i'm able to split the docs according to the authors
and then on sub-aggregation i pull the document ids those people are
related to.
What i need is instead of getting only the ids (local_id) to get more
fields of document. I can use terms + script but again i have one value
back. Which is
something like :

{
"size": 0,
"fields" : ["title"],
"aggs": {
"group_by_authors": {
"terms": {
"script": "doc['authors.name'].value + '|' +
doc['authors.email'].value"
},
"aggs":{
"get_by_local_id":{
"terms":{
"field":"local_id",
"script":"doc['type'].value"
}
}
}
}
}
}

I can do some magic with script to get more values and then parse it in my
code but, it becomes very ugly. On docs it says it is possible to get
multiple
values back on aggregation. Any examples would be very useful.

Thanks in advance.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ea280fc8-ad63-41e2-bf8a-d1668eec9640%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.