KIBANA ElasticQuery from java
<p>I would like to fire this REST GET API cal from java    </p>

<pre><code> curl -x 'http://localhost:9200' -d '{
     "size": 0,
     "aggs": {
       "2": {
         "terms": {
           "field": "message_user_uid",
           "size": 10,
           "order": {
             "_count": "desc"
           }
         }
       }
     },
     "query": {
       "filtered": {
         "query": {
           "query_string": {
             "query": "_key: \"my-demo-exchange-*\" AND message_message: \"success\"",
             "analyze_wildcard": true
           }
         },
         "filter": {
           "bool": {
             "must": [
               {
                 "range": {
                   "@timestamp": {
                     "gte": 1457261289759,
                     "lte": 1457347689760,
                     "format": "epoch_millis"
                   }
                 }
               }
             ],
             "must_not": []
           }
         }
       }
     },
     "highlight": {
       "pre_tags": [
         "@kibana-highlighted-field@"
       ],
       "post_tags": [
         "@/kibana-highlighted-field@"
       ],
       "fields": {
         "*": {}
       },
       "require_field_match": false,
       "fragment_size": 2147483647
     }
    }'
</code></pre>

<p>JAVA CODE</p>

<pre><code>try {
            URL url = new URL("above curl expression");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            conn.setRequestProperty("Accept", "application/json");
            if (conn.getResponseCode() != 200) {
                throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
            }
            BufferedReader br = new BufferedReader(new InputStreamReader(
                    (conn.getInputStream())));
            String output="",line;
            System.out.println("Output from Server .... \n");
            while ((line = br.readLine()) != null) {
                    output+=line+"\n";
            }
            conn.disconnect();
            System.out.println(output);
        } catch (Exception e) {
            e.printStackTrace();
        } 
</code></pre>

<p>But it gives an error for </p>

<pre><code>java.net.MalformedURLException: no protocol: curl -x
</code></pre>

<p>So how can I fetch the response from the server for such kind of elastic search.
I found lots on the google and also on stack but not got any proper response.
I want that this java program should run this query and return me that output.
But this SIMPLE REST GET Call program is not working in this case.</p>

<p>Now I am using this code</p>

<pre><code>Client client = TransportClient.builder().build().addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("kibana host IP Address"), 9200));
        GetResponse getResponse=client.prepareGet().execute().get();
        System.out.println(getResponse.toString());
</code></pre>

<p>But it gives me an error</p>

<pre><code>Error : None of the configured nodes are available: [{#transport#-1}{host IP}{host IP:9200}]
</code></pre>