Hi I have an elasticsearch index which needs to deleted when a new entry of that type has inserted. I was able create a shellscript file and insert data into elasticsearch with a java appliaction as below,
public static void main(String[] args) {
try {
// Run the process
/*Runtime.getRuntime().exec("cd src/resources");*/
Process p = Runtime.getRuntime().exec("sh src/resources/test.sh");
// Get the input stream
InputStream is = p.getInputStream();
// Read script execution results
int i;
StringBuffer sb = new StringBuffer();
while ((i = is.read()) != -1)
sb.append((char) i);
System.out.println(sb.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
Test.sh
curl -XDELETE http://localhost:9200/pokedex
With my java program it was possible to insert data but I can't delete, I tried to run the above command in command-line and it worked fine. What is happening here? Why is it executing in command-line and not in my program?
exec? Maybe shell is returning error code but you are ignoring it.