From 50462fc45972260bc4ceba4de82f22bde31c3a4d Mon Sep 17 00:00:00 2001 From: Vasilije Milic Date: Wed, 16 Aug 2023 14:54:14 +0200 Subject: [PATCH] Fix toJson method --- .../src/main/scala/zio/elasticsearch/query/Queries.scala | 2 +- .../src/test/scala/zio/elasticsearch/ElasticQuerySpec.scala | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/library/src/main/scala/zio/elasticsearch/query/Queries.scala b/modules/library/src/main/scala/zio/elasticsearch/query/Queries.scala index d7766d938..e865b168a 100644 --- a/modules/library/src/main/scala/zio/elasticsearch/query/Queries.scala +++ b/modules/library/src/main/scala/zio/elasticsearch/query/Queries.scala @@ -590,7 +590,7 @@ private[elasticsearch] final case class MatchPhrasePrefix[S](field: String, valu extends MatchPhrasePrefixQuery[S] { private[elasticsearch] def toJson(fieldPath: Option[String]): Json = - Obj("match_phrase_prefix" -> Obj(fieldPath.foldRight(field)(_ + "." + _) -> value.toJson)) + Obj("match_phrase_prefix" -> Obj(fieldPath.foldRight(field)(_ + "." + _) -> Obj("query" -> value.toJson))) } sealed trait NestedQuery[S] diff --git a/modules/library/src/test/scala/zio/elasticsearch/ElasticQuerySpec.scala b/modules/library/src/test/scala/zio/elasticsearch/ElasticQuerySpec.scala index 2d4bd4515..376e3ae6b 100644 --- a/modules/library/src/test/scala/zio/elasticsearch/ElasticQuerySpec.scala +++ b/modules/library/src/test/scala/zio/elasticsearch/ElasticQuerySpec.scala @@ -2485,7 +2485,9 @@ object ElasticQuerySpec extends ZIOSpecDefault { """ |{ | "match_phrase_prefix": { - | "stringField": "test" + | "stringField": { + | "query" : "test" + | } | } |} |""".stripMargin