Creating an HTTP client

An HTTP client is one of the easiest clients to create. It's very handy because it allows calling not only internal methods as the native protocol does, but also third-party calls implemented in plugins that can be called only via HTTP.

Getting ready

You will need a working ElasticSearch cluster and Maven installed. The code of this recipe is in the chapter_10/http_client directory, present in the code bundle available on the Packt website and on GitHub (

How to do it...

To create an HTTP client, we will perform the following steps:

  1. For these examples, we have chosen the Apache HttpComponents, one of the most widely used libraries for executing HTTP calls. This ...

Get ElasticSearch Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.