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

Getting a mapping


After having set our mappings for processing types, we sometimes need to control or analyze the mapping to prevent issues. The action to get the mapping for a type helps us to understand the record structure, or its evolution due to merging and implicit type guessing.

Getting ready

You will need a working ElasticSearch cluster and the mapping created in the previous recipe.

How to do it...

The HTTP method to get a mapping is GET.

The URL formats for getting a mapping are:

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

To get a mapping from the type of an index, we will perform the following steps:

  1. If we consider the type order of the previous chapter, the call will be:

    curl -XGET 'http://localhost:9200/myindex/order/_mapping?pretty=true'
    

    The pretty argument in the URL will pretty print the response output.

  2. The result returned by ElasticSearch should be:

    {
      "myindex" : {
        "mappings...