Elastic4s NoNodeAvailableException when connecting via TcpClient.transport

I am trying to take elastic4s

on one of the samples as stated here

But I keep getting the following exception when I try to connect via TcpClient.transport:

Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{IFyYWnE_S4aHRVxT9v60LQ}{dockerhost}{}]]


I am trying to connect to elastic instance on docker, version elastic

is 2.3.4

Here is my code below dependencies.

import com.sksamuel.elastic4s.{ElasticClient, ElasticsearchClientUri, TcpClient}
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy
import org.elasticsearch.common.settings.Settings
import com.sksamuel.elastic4s.ElasticDsl._

object Main extends App {
  //val settings = Settings.builder().put("cluster.name", "elasticsearch").build()
  val client = TcpClient.transport(ElasticsearchClientUri("elasticsearch://dockerhost:9300"))

  client.execute {
    indexInto("myindex" / "mytype").fields("country" -> "Mongolia", "capital" -> "Ulaanbaatar"),
    indexInto("myindex" / "mytype").fields("country" -> "Namibia", "capital" -> "Windhoek")

  val result = client.execute {
    search("myindex").matchQuery("capital", "ulaanbaatar")





compile group: 'com.sksamuel.elastic4s', name: 'elastic4s-core_2.11', version: '5.4.9'
compile group: 'com.sksamuel.elastic4s', name: 'elastic4s-tcp_2.11', version: '5.4.9'
compile group: 'com.sksamuel.elastic4s', name: 'elastic4s-http_2.11', version: '5.4.9'
compile group: 'com.sksamuel.elastic4s', name: 'elastic4s-streams_2.11', version: '5.4.9'


Any help on this issue would be helpful.


source to share

1 answer

I get asked this question a lot, and 99% of the time the answer is



All Articles