Skip to content

Instantly share code, notes, and snippets.

@bevankoopman
Last active July 13, 2016 00:31
Show Gist options
  • Save bevankoopman/6c135682a73dfefba23d1a106a1d4d14 to your computer and use it in GitHub Desktop.
Save bevankoopman/6c135682a73dfefba23d1a106a1d4d14 to your computer and use it in GitHub Desktop.
HttpPost post = new HttpPost(Configuration.getElasticIndexURL() + "/trial/_bulk");
post.setEntity(new FileEntity(jsonFile));
post.addHeader("content-type", "text/plain");
post.addHeader("Accept", "text/plain");
HttpResponse response = HttpClientBuilder.create().build().execute(post);
if (response.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_OK) {
log.debug("Index complete for " + jsonFile);
} else {
log.warn("Error received when indexings " + jsonFile + " " + new BufferedReader(new InputStreamReader(response.getEntity().getContent())).readLine());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment