diff --git a/quesma/queryparser/query_parser.go b/quesma/queryparser/query_parser.go index bcd2f01c3..dd14bf668 100644 --- a/quesma/queryparser/query_parser.go +++ b/quesma/queryparser/query_parser.go @@ -1262,6 +1262,13 @@ func (cw *ClickhouseQueryTranslator) parseSize(queryMap QueryMap, defaultSize in return defaultSize } else if sizeAsFloat, ok := sizeRaw.(float64); ok { return int(sizeAsFloat) + } else if sizeAsString, ok := sizeRaw.(string); ok { + if sizeAsInt, err := strconv.Atoi(sizeAsString); err == nil { + return sizeAsInt + } else { + logger.WarnWithCtx(cw.Ctx).Msgf("invalid size type: %T, value: %v. Expected int", sizeRaw, sizeRaw) + return defaultSize + } } else { logger.WarnWithCtx(cw.Ctx).Msgf("invalid size type: %T, value: %v. Expected float64", sizeRaw, sizeRaw) return defaultSize diff --git a/quesma/testdata/aggregation_requests.go b/quesma/testdata/aggregation_requests.go index d2d9f46c2..c8b5e9591 100644 --- a/quesma/testdata/aggregation_requests.go +++ b/quesma/testdata/aggregation_requests.go @@ -318,7 +318,7 @@ var AggregationTests = []AggregationTestCase{ LIMIT 1001`, }, { // [2] - TestName: "date_histogram", + TestName: "date_histogram + size as string", QueryRequestJson: ` { "_source": { @@ -345,7 +345,7 @@ var AggregationTests = []AggregationTestCase{ "_count": "desc" }, "shard_size": 25, - "size": 10 + "size": "10" } } },