diff --git a/modules/library/src/main/scala/zio/elasticsearch/ElasticQuery.scala b/modules/library/src/main/scala/zio/elasticsearch/ElasticQuery.scala index 3b4a35e7e..b3c4a2315 100644 --- a/modules/library/src/main/scala/zio/elasticsearch/ElasticQuery.scala +++ b/modules/library/src/main/scala/zio/elasticsearch/ElasticQuery.scala @@ -129,6 +129,9 @@ object ElasticQuery { def filter(queries: ElasticQuery[_]*): BoolQuery = self.copy(filter = filter ++ queries) + def must(queries: ElasticQuery[_]*): BoolQuery = + self.copy(must = must ++ queries) + def paramsToJson: Json = Obj( "bool" -> Obj( "filter" -> Arr(filter.map(_.toJson): _*), @@ -137,9 +140,6 @@ object ElasticQuery { ) ) - def must(queries: ElasticQuery[_]*): BoolQuery = - self.copy(must = must ++ queries) - def should(queries: ElasticQuery[_]*): BoolQuery = self.copy(should = should ++ queries) } diff --git a/modules/library/src/test/scala/zio/elasticsearch/QueryDSLSpec.scala b/modules/library/src/test/scala/zio/elasticsearch/QueryDSLSpec.scala index 7e6f0ef00..0755b4614 100644 --- a/modules/library/src/test/scala/zio/elasticsearch/QueryDSLSpec.scala +++ b/modules/library/src/test/scala/zio/elasticsearch/QueryDSLSpec.scala @@ -38,7 +38,7 @@ object QueryDSLSpec extends ZIOSpecDefault { val (id, name, address, balance, age) = schema.makeAccessors(ElasticQueryAccessorBuilder) } - def spec: Spec[Environment with TestEnvironment with Scope, Any] = + override def spec: Spec[Environment with TestEnvironment with Scope, Any] = suite("Query DSL")( suite("creating ElasticQuery")( test("successfully create Match query using `matches` method") { @@ -195,7 +195,7 @@ object QueryDSLSpec extends ZIOSpecDefault { test("successfully create MatchAll Query") { val query = matchAll - assert(query)(equalTo(MatchAllQuery(boost = None))) + assert(query)(equalTo(MatchAllQuery(None))) }, test("successfully create MatchAll Query with boost") { val query = matchAll.boost(1.0) @@ -474,7 +474,7 @@ object QueryDSLSpec extends ZIOSpecDefault { |} |""".stripMargin - assert(query.toJsonBody)(equalTo(expected.toJson)) + assert(query.toJson)(equalTo(expected.toJson)) }, test("properly encode Bool Query with Must containing `Match` leaf query") { val query = boolQuery.must(matches(field = "day_of_week", value = "Monday"))