Java REST API - GET Request - Illegal Argument Exception

Hello,

I'm new to elastic, and I have gone over the basic documentation available here.

https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_example_requests.html

Unfortunately the example provided is a bit trivial, and since I'm new to Elastic in general I suspect I'm missing something basic. I have the following code that works as expected (200 Status Code).

RestClient restClient = RestClient.builder(new HttpHost("myHostName", 9200, "http")).build();
Map<String, String> params = new HashMap<String, String>();
params.put("pretty", "true");

Response elasticRsp = restClient.performRequest("GET", "/myIndexName", params);
LOG.info("Elastic Response Status Code " + elasticRsp.getStatusLine().getStatusCode());

My problem is that once I try to add additional parameters that I think should work to the params map I get Illegal Argument Exceptions. I have tried to add additional lines of code such as:

params.put("default_operator", "AND");

OR

params.put("query", "My Query String");

Can someone PLEASE provide a more robust example and a link to the documentation that shows what keys I can use in the map?

Here are the keys you can use in the map: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.