Made all multi-bucket aggs return consistent response format
Closes #4926
This commit is contained in:
parent
f9d1552282
commit
dd389d1cc5
|
@ -111,7 +111,8 @@ Response:
|
|||
--------------------------------------------------
|
||||
{
|
||||
"aggregations": {
|
||||
"articles_over_time": [
|
||||
"articles_over_time": {
|
||||
"buckets": [
|
||||
{
|
||||
"key_as_string": "2013-02-02",
|
||||
"key": 1328140800000,
|
||||
|
@ -125,6 +126,7 @@ Response:
|
|||
...
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ Response:
|
|||
...
|
||||
|
||||
"aggregations": {
|
||||
"range": [
|
||||
"range": {
|
||||
"buckets": [
|
||||
{
|
||||
"to": 1.3437792E+12,
|
||||
"to_as_string": "08-2012",
|
||||
|
@ -47,6 +48,7 @@ Response:
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@ Response:
|
|||
--------------------------------------------------
|
||||
{
|
||||
"aggregations": {
|
||||
"rings": [
|
||||
"rings" : {
|
||||
"buckets": [
|
||||
{
|
||||
"unit": "km",
|
||||
"to": 100.0,
|
||||
|
@ -47,6 +48,7 @@ Response:
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ And the following may be the response:
|
|||
--------------------------------------------------
|
||||
{
|
||||
"aggregations": {
|
||||
"prices": [
|
||||
"prices" : {
|
||||
"buckets": [
|
||||
{
|
||||
"key": 0,
|
||||
"doc_count": 2
|
||||
|
@ -49,6 +50,7 @@ And the following may be the response:
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
||||
|
@ -75,7 +77,8 @@ Response:
|
|||
--------------------------------------------------
|
||||
{
|
||||
"aggregations": {
|
||||
"prices": [
|
||||
"prices" : {
|
||||
"buckets": [
|
||||
{
|
||||
"key": 0,
|
||||
"doc_count": 2
|
||||
|
@ -94,6 +97,7 @@ Response:
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
||||
|
@ -187,6 +191,7 @@ NOTE: The special value `0` can be used to add empty buckets to the response b
|
|||
{
|
||||
"aggregations": {
|
||||
"prices": {
|
||||
"buckets": {
|
||||
"0": {
|
||||
"key": 0,
|
||||
"doc_count": 2
|
||||
|
@ -213,6 +218,7 @@ NOTE: The special value `0` can be used to add empty buckets to the response b
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
||||
|
@ -242,6 +248,7 @@ Response:
|
|||
{
|
||||
"aggregations": {
|
||||
"prices": {
|
||||
"buckets": {
|
||||
"0": {
|
||||
"key": 0,
|
||||
"doc_count": 2
|
||||
|
@ -256,5 +263,6 @@ Response:
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
|
|
@ -30,7 +30,8 @@ Response:
|
|||
...
|
||||
|
||||
"aggregations": {
|
||||
"ip_ranges": [
|
||||
"ip_ranges":
|
||||
"buckets" : [
|
||||
{
|
||||
"to": 167772165,
|
||||
"to_as_string": "10.0.0.5",
|
||||
|
@ -43,6 +44,7 @@ Response:
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
||||
|
@ -71,7 +73,8 @@ Response:
|
|||
--------------------------------------------------
|
||||
{
|
||||
"aggregations": {
|
||||
"ip_ranges": [
|
||||
"ip_ranges": {
|
||||
"buckets": [
|
||||
{
|
||||
"key": "10.0.0.0/25",
|
||||
"from": 1.6777216E+8,
|
||||
|
@ -90,5 +93,6 @@ Response:
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
|
@ -31,7 +31,8 @@ Response:
|
|||
...
|
||||
|
||||
"aggregations": {
|
||||
"price_ranges": [
|
||||
"price_ranges" : {
|
||||
"buckets": [
|
||||
{
|
||||
"to": 50,
|
||||
"doc_count": 2
|
||||
|
@ -47,6 +48,7 @@ Response:
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
||||
|
@ -81,7 +83,8 @@ Response:
|
|||
...
|
||||
|
||||
"aggregations": {
|
||||
"price_ranges": {
|
||||
"price_ranges" : {
|
||||
"buckets": {
|
||||
"*-50.0": {
|
||||
"to": 50,
|
||||
"doc_count": 2
|
||||
|
@ -97,6 +100,7 @@ Response:
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
||||
|
@ -200,7 +204,8 @@ Response:
|
|||
--------------------------------------------------
|
||||
{
|
||||
"aggregations": {
|
||||
"price_ranges": [
|
||||
"price_ranges" : {
|
||||
"buckets": [
|
||||
{
|
||||
"to": 50,
|
||||
"doc_count": 2,
|
||||
|
@ -237,6 +242,7 @@ Response:
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
||||
|
|
|
@ -274,8 +274,8 @@ There are two mechanisms by which terms aggregations can be executed: either by
|
|||
data per-bucket (`map`), or by using ordinals of the field values instead of the values themselves (`ordinals`). Although the
|
||||
latter execution mode can be expected to be slightly faster, it is only available for use when the underlying data source exposes
|
||||
those terms ordinals. Moreover, it may actually be slower if most field values are unique. Elasticsearch tries to have sensible
|
||||
defaults when it comes to the execution mode that should be used, but in case you know that an execution mode may perform better
|
||||
than the other one, you have the ability to provide Elasticsearch with a hint:
|
||||
defaults when it comes to the execution mode that should be used, but in case you know that one execution mode may perform better
|
||||
than the other one, you have the ability to "hint" it to Elasticsearch:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
|
|
|
@ -363,10 +363,11 @@ public class InternalHistogram<B extends InternalHistogram.Bucket> extends Inter
|
|||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
if (keyed) {
|
||||
builder.startObject(name);
|
||||
if (keyed) {
|
||||
builder.startObject(CommonFields.BUCKETS);
|
||||
} else {
|
||||
builder.startArray(name);
|
||||
builder.startArray(CommonFields.BUCKETS);
|
||||
}
|
||||
|
||||
for (B bucket : buckets) {
|
||||
|
@ -396,7 +397,7 @@ public class InternalHistogram<B extends InternalHistogram.Bucket> extends Inter
|
|||
} else {
|
||||
builder.endArray();
|
||||
}
|
||||
return builder;
|
||||
return builder.endObject();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -294,26 +294,27 @@ public class InternalRange<B extends InternalRange.Bucket> extends InternalAggre
|
|||
out.writeDouble(((Bucket) bucket).from);
|
||||
out.writeDouble(((Bucket) bucket).to);
|
||||
out.writeVLong(((Bucket) bucket).docCount);
|
||||
((Bucket) bucket).aggregations.writeTo(out);
|
||||
bucket.aggregations.writeTo(out);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
if (keyed) {
|
||||
builder.startObject(name);
|
||||
if (keyed) {
|
||||
builder.startObject(CommonFields.BUCKETS);
|
||||
} else {
|
||||
builder.startArray(name);
|
||||
builder.startArray(CommonFields.BUCKETS);
|
||||
}
|
||||
for (B range : ranges) {
|
||||
((Bucket) range).toXContent(builder, params, formatter, keyed);
|
||||
range.toXContent(builder, params, formatter, keyed);
|
||||
}
|
||||
if (keyed) {
|
||||
builder.endObject();
|
||||
} else {
|
||||
builder.endArray();
|
||||
}
|
||||
return builder;
|
||||
return builder.endObject();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue