Search code examples
javaelasticsearchcygwin

Elasticsearch output -- how to remove heading on Java calls


I'm running Elasticsearch commands from within Java, using Process and ProcessBuilder, on Windows:

new ProcessBuilder(command);

command here is the array of commands:

"C:\\cygwin64\\bin\\curl", "-XGET", "'"+ES_BASE_URL+"index2/_search?pretty'"

The output is fine-- except that the following is prepended to the Cygwin output, i.e. the output i get from Cygwin when i run it directly on a Cygwin terminal:

% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed

0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 796 100 796 0 0 27298 0 --:--:-- --:--:-- --:--:-- 31840

How to avoid this so that i get bare JSon result, the result i get from Cygwin?


Solution

  • curl -s -XGET

    should suppress meter. ( You can also reduce it to just a progress bar instead of those numbers by curl -# )

    From curl manual:

    -#, --progress-bar Make curl display progress as a simple progress bar instead of the standard, more informational, meter.

    -s, --silent Silent or quiet mode. Don't show progress meter or error messages. Makes Curl mute. It will still output the data you ask for, potentially even to the terminal/stdout unless you redirect it.