Optimizing an index

The core of ElasticSearch is based on Lucene, which stores the data in segments on the disk. During the life of an Index, a lot of segments are created and changed. With the increase of segment numbers, the speed of search decreases due to the time required to read all of them. The optimize operation allows us to consolidate the index for faster search performance, reducing segments.

Getting ready

You will need a working ElasticSearch cluster and the index created in the Creating an index recipe in this chapter.

How to do it...

The URL format to optimize one or more indices is:

http://<server>/<index_name(s)>/_optimize

The URL format to optimize all the indices in a cluster is:

http://<server>/_optimize

The HTTP method used is POST. ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.