From 39526600816c62fee8f2d08da70ce86c00ca20eb Mon Sep 17 00:00:00 2001 From: Dimitrije Bulaja Date: Tue, 29 Nov 2022 16:54:14 +0100 Subject: [PATCH] Add routing param --- .../src/main/scala/zio/elasticsearch/ElasticRequest.scala | 3 ++- .../main/scala/zio/elasticsearch/HttpElasticExecutor.scala | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/library/src/main/scala/zio/elasticsearch/ElasticRequest.scala b/modules/library/src/main/scala/zio/elasticsearch/ElasticRequest.scala index 7b39fb840..58221d4f7 100644 --- a/modules/library/src/main/scala/zio/elasticsearch/ElasticRequest.scala +++ b/modules/library/src/main/scala/zio/elasticsearch/ElasticRequest.scala @@ -70,7 +70,8 @@ object ElasticRequest { private[elasticsearch] final case class Exists( index: IndexName, - id: DocumentId + id: DocumentId, + routing: Option[Routing] = None ) extends ElasticRequest[Boolean] private[elasticsearch] final case class GetById( diff --git a/modules/library/src/main/scala/zio/elasticsearch/HttpElasticExecutor.scala b/modules/library/src/main/scala/zio/elasticsearch/HttpElasticExecutor.scala index d8acd784d..a8db81fd3 100644 --- a/modules/library/src/main/scala/zio/elasticsearch/HttpElasticExecutor.scala +++ b/modules/library/src/main/scala/zio/elasticsearch/HttpElasticExecutor.scala @@ -74,12 +74,13 @@ private[elasticsearch] final class HttpElasticExecutor private (config: ElasticC .unit } - private def executeExists(r: Exists): Task[Boolean] = + private def executeExists(r: Exists): Task[Boolean] = { + val uri = uri"$basePath/${r.index}/$Doc/${r.id}".withParam("routing", r.routing.map(_.value)) request - .get(uri"$basePath/${r.index}/$Doc/${r.id}") - .response(asJson[ElasticGetResponse]) + .head(uri) .send(client) .map(_.code.equals(Ok)) + } }