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 ...

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.