Create a Index in ElasticSearch on Issue creation

vaishal June 9, 2017

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

 

1 answer

0 votes
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 9, 2023

Hi @vaishal ,

are you sure that your target url doesn't require authentication?

Fabio

Suggest an answer

Log in or Sign up to answer