Elastic4s won't quit
I tried to run elastic4s example code as below:
import com.sksamuel.elastic4s.ElasticClient
import com.sksamuel.elastic4s.ElasticDsl._
object hw extends App {
val client = ElasticClient.local
client.execute(create index "bands")
client.execute { index into "bands/artists" fields "name"->"coldplay" }.await
val resp = client.execute { search in "bands/artists" query "coldplay" }.await
println(resp)
client.close
}
The program prints the results correctly, but does not exit by itself. I don't know if there are any problems with my code or environment.
+3
source to share
1 answer
Try to use shutdown
. shutdown
actually delegates prepareNodesShutdown
which is the ClusterAdminClient method and shuts down node. shutdown
without any arguments will disable the local node.
EDIT : Added code and javadoc link
The following worked for me and worked as expected with optim4s 1.4.0 (i.e. main exits)
import com.sksamuel.elastic4s.ElasticClient
import com.sksamuel.elastic4s.ElasticDsl._
object Main extends App {
val client = ElasticClient.local
client.execute(create index "bands")
client.execute { index into "bands/artists" fields "name"->"coldplay" }.await
val resp = client.execute { search in "bands/artists" query "coldplay" }.await
println(resp)
client.close()
client.shutdown
}
+2
source to share