Hi
I am trying to create Index in ElasticSearch using REST API on Issue creation.
I had written Groovy script in Script Runner function but I am not able to create Index.
I am trying to debug below script in Post function but it is not running.
Could anyone please help me out here.
import groovy.json.JsonSlurper;
import groovy.json.StreamingJsonBuilder;
def body_req = [
    settings: [index:[number_of_shards:3,number_of_replicas:2]]
]
 
def baseURL = "http://localhost:9200/JiraTicket";
URL url;
 
url = new URL(baseURL);
 
URLConnection connection = url.openConnection() as HttpURLConnection;
connection.requestMethod = "PUT" 
connection.doOutput = true 
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8")
connection.outputStream.withWriter("UTF-8") { new StreamingJsonBuilder(it, body_req) }
connection.connect();Thanks ,
Vaishal
 
 
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.