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

Speeding up GET operations (multi GET)


The standard GET operation is very fast, but if you need to fetch a lot of documents by the ID, ElasticSearch provides multi GET operations.

Getting ready

You will need a working ElasticSearch Cluster and the document indexed from the Indexing a document recipe in this chapter.

How to do it...

The multi GET REST URLs are:

http://<server</_mget
http://<server>/<index_name>/_mget
http://<server>/<index_name>/<type_name>/_mget

To execute a multi GET action, we will perform the following steps:

  1. The method is POST with a body that contains a list of document IDs and the Index/type if they are missing. As an example, using the first URL, we need to provide the Index, type, and ID:

    curl –XPOST 'localhost:9200/_mget' -d '{
      "docs" : [
        {
          "_index" : "myindex",
          "_type" : "order",
          "_id" : "2qLrAfPVQvCRMe7Ku8r0Tw"
        },
        {
          "_index" : "myindex",
          "_type" : "order",
          "_id" : "2"
        }
      ]
    }'
    

    This...