Nested Aggregations - Java API


(Robert Douglas) #1

Hi all,

I'm working on putting together a query that requires nested aggregations
in the form:

"aggs": {
"steve_unique": {
"filter": {
"term": {
"user.screen_name": "steve"
}
},
"aggs": {
"unique": {
"cardinality": {
"field": "entities.hashtags.text"
}
}
}
}
}

Looking through the API, I'm not noticing an obvious way to go about
forming this part of the query. Is there something built in that would
facilitate this?

Thanks,
Robert

--
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/c9d2bd76-9a4b-44e7-a40a-708894c63cc0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Adrien Grand) #2

Hi,

You should be able to do it with the Java API with something like
(untested):

AggregationBuildersfilter("steve_unique").filter(FilterBuilders.termFilter("user.screen_name",
"steve")).subAggregation(AggregationBuilders.cardinality("unique").field("entities.hashtags.text"))

On Mon, Apr 14, 2014 at 8:21 PM, Robert Douglas robertd89@gmail.com wrote:

Hi all,

I'm working on putting together a query that requires nested aggregations
in the form:

"aggs": {
"steve_unique": {
"filter": {
"term": {
"user.screen_name": "steve"
}
},
"aggs": {
"unique": {
"cardinality": {
"field": "entities.hashtags.text"
}
}
}
}
}

Looking through the API, I'm not noticing an obvious way to go about
forming this part of the query. Is there something built in that would
facilitate this?

Thanks,
Robert

--
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/c9d2bd76-9a4b-44e7-a40a-708894c63cc0%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/c9d2bd76-9a4b-44e7-a40a-708894c63cc0%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Adrien Grand

--
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/CAL6Z4j6ufTa6Mb%3Dq3EnuCVx4g6-0jzT7d64j-ODxWVnWHGG5sQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(Sumit Gupta) #3

Hi,

I am searching the same thing but there is no java api for ES aggregation so you can use generate json using XContentBuilder and perform Java Search api in that json.I do it in the same way.

Thanks,
Sumit


(Saravanan Shanmugasundaram) #4

Hi,

I am trying to create nested aggregations on list of strings.

for e.g
{aggs : {property1 : aggs : { property2 : aggs : property 3 } } }

I dont think, there are current functionalities to do so.

Regards,
Saravanan.


(system) #5