Advertisement
Guest User

getHttpPost

a guest
Apr 25th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. Add this to ElasticSearchConnection.java
  2.  
  3.  
  4. public HttpPost getHttpPostQueryFromJsonString(String jsonString) throws ParseException {
  5. JSONObject job = (JSONObject) this.parser.parse(jsonString);
  6. String tmpIndex = (String) job.get("els_index_str");
  7. if (tmpIndex == null || tmpIndex.trim().isEmpty()) {
  8. tmpIndex = this.index;
  9. } else {
  10. job.remove("els_index_str");
  11. }
  12. String tmpType = (String) job.get("els_type_str");
  13. if (tmpType == null || tmpType.trim().isEmpty()) {
  14. tmpType = this.type;
  15. } else {
  16. job.remove("els_type_str");
  17. }
  18. String fullHostString = esearchHost + "/" + tmpIndex + "/" + tmpType + "/_search";
  19. // System.out.println("host:"+fullHostString);
  20. HttpPost httpPost = new HttpPost(fullHostString);
  21. HttpEntity entity = new StringEntity(job.toJSONString(), "UTF-8");
  22. httpPost.setEntity(entity);
  23.  
  24. return httpPost;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement