Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- StringBuilder sb = new StringBuilder();
- sb.append("{"index" : "indexname", "type": "typename"}");
- sb.append("{"query" : {"match_all" : {}}, "from" : 0, "size" : 10}");
- sb.append("{"index" : "indexname", "type": "typename"}");
- sb.append("{"query" : {"match_all" : {}}}n");
- String query = sb.toString();
- String fullURL = "http://esHost/_msearch";
- log.debug("URL to search: {}.", fullURL);
- log.info(">>>>" + query);
- HttpHeaders headers = new HttpHeaders();
- headers.add("Content-Type", "application/x-ndjson");
- HttpEntity<String> request = new HttpEntity<>(query, headers);
- Map map = restTemplate.postForObject(fullURL, request, Map.class);
- ...
- {"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: no requests added;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: no requests added;"},"status":400}
- private static final String NEW_LINE = System.getProperty("line.separator");
- sb.append("{"index" : "indexname", "type": "typename"}").append(NEW_LINE)
- sb.append("{"query" : {"match_all" : {}}, "from" : 0, "size" : 10}").append(NEW_LINE)
- sb.append("{"index" : "indexname", "type": "typename"}").append(NEW_LINE)
- sb.append("{"query" : {"match_all" : {}}}n").append(NEW_LINE);
Add Comment
Please, Sign In to add comment