Skip to content

Commit

Permalink
(executor): Simplify create method (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbulaja98 authored Dec 1, 2022
1 parent 1ff4c67 commit cd0e66a
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,15 @@ private[elasticsearch] final class HttpElasticExecutor private (config: ElasticC
}

private def executeCreate(r: Create): Task[Option[DocumentId]] = {
def createUri(maybeDocumentId: Option[DocumentId]) =
maybeDocumentId match {
case Some(documentId) =>
uri"$basePath/${r.index}/$Create/$documentId".withParam("routing", r.routing.map(_.value))
case None =>
uri"$basePath/${r.index}/$Doc".withParam("routing", r.routing.map(_.value))
}
val uri = r.id match {
case Some(documentId) =>
uri"$basePath/${r.index}/$Create/$documentId".withParam("routing", r.routing.map(_.value))
case None =>
uri"$basePath/${r.index}/$Doc".withParam("routing", r.routing.map(_.value))
}

request
.post(createUri(r.id))
.post(uri)
.contentType(ApplicationJson)
.response(asJson[ElasticCreateResponse])
.body(r.document.json)
Expand Down

0 comments on commit cd0e66a

Please sign in to comment.