Creating a client

The official ElasticSearch clients are designed to support several transport layers. They allow you to use HTTP, Thrift, or the Memcached protocol without changing your application code.

The Thrift and Memcached protocols are binary ones and, due to their structures, they are generally a bit faster than the HTTP one. They are wrapped in the REST API and share the same behavior, so switching between these protocols is easy.

In this recipe, we'll see how to instantiate a client with the different protocols.

Getting ready

You need a working ElasticSearch cluster and plugins for extra protocols. The full code of this recipe is in the chapter_11/ file, available in the code bundle of this book and on GitHub ( ...

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.