Elasticseach Java High Level client

I need to convert String object to Json object in spring boot
i have coded like this but through error

public Map<String, Object> datesearch() throws IOException
	 {
		 SearchRequest searchRequest = new SearchRequest();
		 searchRequest.indices("check1");
		 SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); 
		 searchSourceBuilder.query(QueryBuilders.rangeQuery("date").from("2019-10-01").to("2019-10-03")); 
		 searchRequest.source(searchSourceBuilder); 
		 
		 SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);

		XContentBuilder builder = XContentFactory.jsonBuilder();
		searchResponse.toXContent(builder, ToXContent.EMPTY_PARAMS);
		JSONObject json = new JSONObject(builder.toString()); // error at this line
		 return json;
	    }

This is probably a question you need to ask to the JSONObject class author.
From which library this class is coming?

BTW you can just do searchResponse.toString() to get the JSON version of the response object.

yah i did that
I need another help?

instead of having Winlogbeat create daily indices We can create separate index for logs from different client(Different machine) to one elasticsearch server

How to do?

That's a non related question. Please open a new question in #beats:winlogbeat

okay Thank you

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