Guest User

Untitled

a guest
May 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. StringBuilder sb = new StringBuilder();
  2. sb.append("{"index" : "indexname", "type": "typename"}");
  3. sb.append("{"query" : {"match_all" : {}}, "from" : 0, "size" : 10}");
  4. sb.append("{"index" : "indexname", "type": "typename"}");
  5. sb.append("{"query" : {"match_all" : {}}}n");
  6.  
  7. String query = sb.toString();
  8.  
  9. String fullURL = "http://esHost/_msearch";
  10.  
  11. log.debug("URL to search: {}.", fullURL);
  12. log.info(">>>>" + query);
  13.  
  14. HttpHeaders headers = new HttpHeaders();
  15. headers.add("Content-Type", "application/x-ndjson");
  16.  
  17. HttpEntity<String> request = new HttpEntity<>(query, headers);
  18.  
  19. Map map = restTemplate.postForObject(fullURL, request, Map.class);
  20. ...
  21.  
  22. {"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}
  23.  
  24. private static final String NEW_LINE = System.getProperty("line.separator");
  25.  
  26. sb.append("{"index" : "indexname", "type": "typename"}").append(NEW_LINE)
  27. sb.append("{"query" : {"match_all" : {}}, "from" : 0, "size" : 10}").append(NEW_LINE)
  28. sb.append("{"index" : "indexname", "type": "typename"}").append(NEW_LINE)
  29. sb.append("{"query" : {"match_all" : {}}}n").append(NEW_LINE);
Add Comment
Please, Sign In to add comment