Refreshing an index

ElasticSearch allows the user to control the state of the searcher using forced refresh on an index. If not forced, the new indexed document will only be searchable after a fixed time interval (usually 1 second).

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 formats for refreshing an index, are:

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

The URL format for refreshing all the indices in a cluster, is:

http://<server>/_refresh

The HTTP method used for both URLs is POST.

To refresh an index, we will perform the following steps:

  1. If we consider the type order of the previous chapter, the call will be:
    curl -XPOST 'http://localhost:9200/myindex/_refresh' ...

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.