Hi,
I am quite beginner in ElasticSearch and Groovy. I have to perform CRUD (Create,Retrieve,Update and Delete) operations in ElasticSearch using Groovy.I am using IntelliJ for Groovy. I have found few lines of codes but getting multiple issues in code.So,couldn't proceed further.
Looking for the suggestions and help.
Thanks.
import org.elasticsearch.client.transport.TransportClient
import org.elasticsearch.action.search.SearchResponse
import org.elasticsearch.action.ListenableActionFuture
TransportClient client = TransportClient.builder().settings(Settings.settingsBuilder {
client.transport.sniff = true
cluster.name = "clustername"
}).build()
client.addTransportAddress( (new TransportAddress(InetAddress.getByName("localhost"), 9200) ))
String userId = "1"
ListenableActionFuture future = client.searchAsync {
indices "index"
types "type"
source {
query {
match {
_id = userId
}
}
}
}
SearchResponse response = future.actionGet()
println response