Skip to content

Commit

Permalink
Return null for aggregations factory even if empty aggs is present in…
Browse files Browse the repository at this point in the history
… search source (#8206) (#8222)

* Return null for aggregations factory even if empty aggs is present in search source



* Update rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/60_empty.yml




---------



(cherry picked from commit 049129c)

Signed-off-by: Jay Deng <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Andriy Redko <[email protected]>
  • Loading branch information
3 people authored Jun 22, 2023
1 parent de9e8dd commit e3d8f7d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
"Empty aggs Body":
- do:
index:
index: test
id: 1
body: { "double" : 42 }

- do:
index:
index: test
id: 2
body: { "double" : 100 }

- do:
index:
index: test
id: 3
body: { "double" : 50 }

- do:
indices.refresh: {}

- do:
search:
rest_total_hits_as_int: true
body: { "size" : 0, "aggs" : { } }

- match: { hits.total: 3 }
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private static AggregatorFactories.Builder parseAggregators(XContentParser parse
}
}

return factories;
return factories.count() > 0 ? factories : null;
}

public static final AggregatorFactories EMPTY = new AggregatorFactories(new AggregatorFactory[0]);
Expand Down

0 comments on commit e3d8f7d

Please sign in to comment.