Skip to content

Commit

Permalink
Fixing hardbound, missing and script test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Ankit Jain <[email protected]>
  • Loading branch information
jainankitk committed Nov 27, 2023
1 parent b401a12 commit 15f9543
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private AutoDateHistogramAggregator(

// Create the filters for fast aggregation only if the query is instance
// of point range query and there aren't any parent/sub aggregations
if (parent() == null && subAggregators.length == 0) {
if (parent() == null && subAggregators.length == 0 && valuesSourceConfig.missing() == null && valuesSourceConfig.script() == null) {
final FieldContext fieldContext = valuesSourceConfig.fieldContext();
if (fieldContext != null) {
final String fieldName = fieldContext.field();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,21 @@ class DateHistogramAggregator extends BucketsAggregator implements SizedBucketAg

// Create the filters for fast aggregation only if the query is instance
// of point range query and there aren't any parent/sub aggregations
if (parent() == null && subAggregators.length == 0) {
if (parent() == null && subAggregators.length == 0 && valuesSourceConfig.missing() == null && valuesSourceConfig.script() == null) {
final FieldContext fieldContext = valuesSourceConfig.fieldContext();
if (fieldContext != null) {
final String fieldName = fieldContext.field();
final long[] bounds = FilterRewriteHelper.getAggregationBounds(context, fieldName);
if (bounds != null) {
assert fieldContext.fieldType() instanceof DateFieldMapper.DateFieldType;
fieldType = (DateFieldMapper.DateFieldType) fieldContext.fieldType();

// Update min/max limit if user specified any hard bounds
if (hardBounds != null) {
bounds[0] = Math.max(bounds[0], hardBounds.getMin());
bounds[1] = Math.min(bounds[1], hardBounds.getMax());
}

filters = FilterRewriteHelper.createFilterForAggregations(
context,
rounding,
Expand Down

0 comments on commit 15f9543

Please sign in to comment.