Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
dbulaja98 committed May 12, 2023
1 parent 3e21d1d commit 3798c12
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private[elasticsearch] final case class BucketSelector(name: String, script: Scr
def withAgg(agg: SingleElasticAggregation): MultipleAggregations =
multipleAggregations.aggregations(self, agg)

private[elasticsearch] def paramsToJson: Json = {
private[elasticsearch] def togJson: Json = {
val bucketsPathJson: Json = Obj("buckets_path" -> bucketsPath.collect { case (scriptVal, path) =>
Obj(scriptVal -> path.toJson)
}.reduce(_ merge _))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,24 +335,41 @@ object ElasticAggregationSpec extends ZIOSpecDefault {
bucketsPath = Map("agg1" -> "aggregation1", "agg2" -> "aggregation2")
)

assert(aggregation1)(
equalTo(
BucketSelector(
name = "aggregation",
script = Script("params.agg1 > 10"),
bucketsPath = Map("agg1" -> "aggregation1")
)
)
) &&
assert(aggregation2)(
equalTo(
BucketSelector(
name = "aggregation",
script = Script("params.agg1 + params.agg2 > 10"),
bucketsPath = Map("agg1" -> "aggregation1", "agg2" -> "aggregation2")
)
)
)
val expected1 =
"""
|{
| "aggregation": {
| "bucket_selector": {
| "buckets_path": {
| "agg1": "aggregation1"
| },
| "script": {
| "source": "params.agg1 > 10"
| }
| }
| }
|}
|""".stripMargin

val expected2 =
"""
|{
| "aggregation": {
| "bucket_selector": {
| "buckets_path": {
| "agg1": "aggregation1",
| "agg2": "aggregation2"
| },
| "script": {
| "source": "params.agg1 + params.agg2 > 10"
| }
| }
| }
|}
|""".stripMargin

assert(aggregation1.toJson)(equalTo(expected1.toJson)) &&
assert(aggregation2.toJson)(equalTo(expected2.toJson))
},
test("bucketSort") {
val aggregationWithFrom = bucketSortAggregation("aggregation").from(5)
Expand Down

0 comments on commit 3798c12

Please sign in to comment.