I tried to run an example code of elastic4s, as follows,
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 correctly prints the results, but it does not exit itself. I don't know if there are problems with my code or environment.
Try using shutdown. shutdown will actually delegate to prepareNodesShutdown, which is a method of ClusterAdminClient and shutdowns a node. shutdown without any argument will shutdown the local node.
EDIT: added code and javadoc link
The following did work for me and worked as expected with elastic4s 1.4.0 (i.e. main is terminated)
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With