I have the following query which i am able to run through command line :
curl -XPOST "http://35.160.73.241:9201/products/_search" -d
"{"query":{"match":{"campaign_id":"12239"}}}"
I need to run the above query using java. I am using the following code :
try {
Process process = Runtime.getRuntime().exec("curl -XPOST
\"http://35.160.73.241:9201/products/_search\" -d
\"{\"query\":{\"match\":{\"campaign_id\":\"12239\"}}}\"");
int resultCode = process.waitFor();
System.out.println(resultCode);
if (resultCode == 0) {
// all is good
}
} catch (Exception ex) {
// process cause
ex.printStackTrace();
}
But it is giving me the following exception :
java.io.IOException: Cannot run program "curl": CreateProcess
error=2, The system cannot find the file specified
Please help me to run the query using Java.