Skip to content

Commit

Permalink
Implement changes in Percentile ranks aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
vanjaftn committed Nov 20, 2023
1 parent bdfd045 commit 3bcdf89
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,13 @@ object ElasticAggregation {
final def percentileRanksAggregation[A: Numeric](
name: String,
field: Field[_, A],
value: A,
values: A*
value: BigDecimal,
values: BigDecimal*
): PercentileRanksAggregation =
PercentileRanks(
name = name,
field = field.toString,
values = Chunk.fromIterable(
implicitly[Numeric[A]].toDouble(value) +: values.map(v => implicitly[Numeric[A]].toDouble(v))
),
values = value +: Chunk.fromIterable(values),
missing = None
)

Expand All @@ -303,18 +301,16 @@ object ElasticAggregation {
* an instance of [[zio.elasticsearch.aggregation.PercentileRanksAggregation]] that represents percentile ranks
* aggregation to be performed.
*/
final def percentileRanksAggregation[A: Numeric](
final def percentileRanksAggregation(
name: String,
field: String,
value: A,
values: A*
value: BigDecimal,
values: BigDecimal*
): PercentileRanksAggregation =
PercentileRanks(
name = name,
field = field,
values = Chunk.fromIterable(
implicitly[Numeric[A]].toDouble(value) +: values.map(v => implicitly[Numeric[A]].toDouble(v))
),
values = value +: Chunk.fromIterable(values),
missing = None
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ sealed trait PercentileRanksAggregation
private[elasticsearch] final case class PercentileRanks(
name: String,
field: String,
values: Chunk[Double],
values: Chunk[BigDecimal],
missing: Option[Double]
) extends PercentileRanksAggregation { self =>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ object ElasticAggregationSpec extends ZIOSpecDefault {
| "aggregation": {
| "percentile_ranks": {
| "field": "testField",
| "values": [5.0, 6.0]
| "values": [5, 6]
| }
| }
|}
Expand All @@ -1171,7 +1171,7 @@ object ElasticAggregationSpec extends ZIOSpecDefault {
| "aggregation": {
| "percentile_ranks": {
| "field": "intField",
| "values": [5.0, 6.0]
| "values": [5, 6]
| }
| }
|}
Expand All @@ -1183,7 +1183,7 @@ object ElasticAggregationSpec extends ZIOSpecDefault {
| "aggregation": {
| "percentile_ranks": {
| "field": "intField",
| "values": [5.0, 6.0],
| "values": [5, 6],
| "missing": 20.0
| }
| }
Expand Down

0 comments on commit 3bcdf89

Please sign in to comment.