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}{192.168.99.100:9300}]]

      

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 {
  bulk(
    indexInto("myindex" / "mytype").fields("country" -> "Mongolia", "capital" -> "Ulaanbaatar"),
    indexInto("myindex" / "mytype").fields("country" -> "Namibia", "capital" -> "Windhoek")
  ).refresh(RefreshPolicy.WAIT_UNTIL)
  }.await

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

  println(result.hits.head.sourceAsString)

  client.close()
}

      

build.gradle:

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.

+3


source to share


1 answer


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



+1


source







All Articles