Book Image

ElasticSearch Cookbook

By : Alberto Paro
Book Image

ElasticSearch Cookbook

By: Alberto Paro

Overview of this book

Table of Contents (20 chapters)
ElasticSearch Cookbook Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Managing indices with the native client


In the previous recipe we saw how to initialize a client to send calls to an ElasticSearch cluster. In this recipe, we will see how to manage indices via client calls.

Getting ready

You will need a working ElasticSearch cluster and a working copy of Maven.

The code of this recipe is in chapter_10/nativeclient in the code bundle, which can be downloaded from Packt's website, and on GitHub (https://github.com/aparo/elasticsearch-cookbook-second-edition). The referred class is IndicesOperations.

How to do it...

The ElasticSearch client maps all index operations under the admin.indices object of the client. Here, all the index operations are listed, such as create, delete, exists, open, close, optimize, and so on.

The following steps show how to retrieve a client and execute the main operations on indices:

  1. The first step is importing the required classes:

    import org.elasticsearch.action.admin.indices.exists.indices. IndicesExistsResponse;
    import org.elasticsearch...