diff --git a/elasticsearch/src/main/scala/akka/stream/alpakka/elasticsearch/impl/ElasticsearchSimpleFlowStage.scala b/elasticsearch/src/main/scala/akka/stream/alpakka/elasticsearch/impl/ElasticsearchSimpleFlowStage.scala index d2d722a722..2780b17972 100644 --- a/elasticsearch/src/main/scala/akka/stream/alpakka/elasticsearch/impl/ElasticsearchSimpleFlowStage.scala +++ b/elasticsearch/src/main/scala/akka/stream/alpakka/elasticsearch/impl/ElasticsearchSimpleFlowStage.scala @@ -6,7 +6,6 @@ package akka.stream.alpakka.elasticsearch.impl import akka.annotation.InternalApi import akka.http.scaladsl.HttpExt -import akka.http.scaladsl.model.Uri.Path import akka.http.scaladsl.model._ import akka.http.scaladsl.unmarshalling.Unmarshal import akka.stream.alpakka.elasticsearch._ @@ -71,7 +70,9 @@ private[elasticsearch] final class ElasticsearchSimpleFlowStage[T, C]( override def onPull(): Unit = tryPull() override def onPush(): Unit = { - val endpoint = if (settings.allowExplicitIndex) "/_bulk" else s"/${elasticsearchParams.indexName}/_bulk" + val endpoint = + if (settings.allowExplicitIndex) baseUri.path ?/ "_bulk" + else baseUri.path ?/ elasticsearchParams.indexName / "_bulk" val (messages, resultsPassthrough) = grab(in) inflight = true val json: String = restApi.toJson(messages) @@ -79,7 +80,7 @@ private[elasticsearch] final class ElasticsearchSimpleFlowStage[T, C]( log.debug("Posting data to Elasticsearch: {}", json) if (json.nonEmpty) { - val uri = baseUri.withPath(Path(endpoint)) + val uri = baseUri.withPath(endpoint) val request = HttpRequest(HttpMethods.POST) .withUri(uri) .withEntity(HttpEntity(NDJsonProtocol.`application/x-ndjson`, json))