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

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'
    
  2. The result returned by ElasticSearch should be:

    {"_shards":{"total":4,"successful":2,"failed":0}}

How it works...

Near Real-Time (NRT) capabilities are automatically managed by ElasticSearch, which automatically...