Book Image

ElasticSearch Cookbook

By : Alberto Paro
Book Image

ElasticSearch Cookbook

By: Alberto Paro

Overview of this book

ElasticSearch is one of the most promising NoSQL technologies available and is built to provide a scalable search solution with built-in support for near real-time search and multi-tenancy. This practical guide is a complete reference for using ElasticSearch and covers 360 degrees of the ElasticSearch ecosystem. We will get started by showing you how to choose the correct transport layer, communicate with the server, and create custom internal actions for boosting tailored needs. Starting with the basics of the ElasticSearch architecture and how to efficiently index, search, and execute analytics on it, you will learn how to extend ElasticSearch by scripting and monitoring its behaviour. Step-by-step, this book will help you to improve your ability to manage data in indexing with more tailored mappings, along with searching and executing analytics with facets. The topics explored in the book also cover how to integrate ElasticSearch with Python and Java applications. This comprehensive guide will allow you to master storing, searching, and analyzing data with ElasticSearch.
Table of Contents (19 chapters)
ElasticSearch Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding generic data to mapping


Sometimes when we are working with our mapping, it is necessary to store some additional data to be used for display purpose, ORM facilities, permissions, or simply to track them in the mapping.

ElasticSearch allows storing every kind of JSON data we want in the mapping, with the special _meta field.

Getting ready

You need a working ElasticSearch cluster

How to do it...

The _meta mapping field can be populated with every data we want. For example:

{
  "order": {
    "_meta": {
      "attr1": ["value1", "value2"],
      "attr2": {
      "attr3": "value3"
      }
    }
  }
}

How it works...

When ElasticSearch processes a mapping and finds a _meta field, it stores it in the global mapping status aligned in all the cluster nodes.

The _meta field is only for storing purposes; it's not indexed and searchable.

It can be used for:

  • Storing the metadata type

  • Storing Object Relational Mapping (ORM) related information

  • Storing type permission information

  • Storing extra type information...