You are previewing ElasticSearch Cookbook.
O'Reilly logo
ElasticSearch Cookbook

Book Description

Over 120 advanced recipes to search, analyze, deploy, manage, and monitor data effectively with ElasticSearch

  • Write native plugins to extend the capabilities of ElasticSearch to boost your business

  • Integrate the power of ElasticSearch in your Java applications using the native API or Python applications, with the ElasticSearch community client

  • Step-by step-instructions to help you easily understand ElasticSearch’s capabilities, that act as a good reference for everyday activities

In Detail

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

  1. ElasticSearch Cookbook
    1. Table of Contents
    2. ElasticSearch Cookbook
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Getting Started
      1. Introduction
      2. Understanding node and cluster
        1. Getting ready
        2. How it works...
        3. There's more...
        4. See also
      3. Understanding node services
        1. Getting ready
        2. How it works...
      4. Managing your data
        1. Getting ready
        2. How it works...
        3. There's more...
          1. Best practice
        4. See also
      5. Understanding cluster, replication, and sharding
        1. Getting ready
        2. How it works...
          1. Best practice
        3. There's more…
          1. How to solve the yellow status
            1. Best practice
          2. How to solve the red status
            1. Best practice
        4. See also
      6. Communicating with ElasticSearch
        1. Getting ready
        2. How it works…
      7. Using the HTTP protocol
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
      8. Using the Native protocol
        1. Getting ready
        2. How to do it…
        3. How it works...
        4. There's more…
        5. See also
      9. Using the Thrift protocol
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more...
        5. See also
    9. 2. Downloading and Setting Up ElasticSearch
      1. Introduction
      2. Downloading and installing ElasticSearch
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Networking setup
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Setting up a node
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      5. Setting up ElasticSearch for Linux systems (advanced)
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      6. Setting up different node types (advanced)
        1. Getting ready
        2. How to do it...
        3. How it works...
      7. Installing a plugin
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      8. Installing a plugin manually
        1. Getting ready
        2. How to do it...
        3. How it works...
      9. Removing a plugin
        1. Getting ready
        2. How to do it...
        3. How it works...
      10. Changing logging settings (advanced)
        1. Getting ready
        2. How to do it...
        3. How it works...
    10. 3. Managing Mapping
      1. Introduction
      2. Using explicit mapping creation
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Mapping base types
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Mapping arrays
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. Mapping an object
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Mapping a document
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Using dynamic templates in document mapping
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      8. Managing nested objects
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      9. Managing a child document
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      10. Mapping a multifield
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      11. Mapping a GeoPoint field
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      12. Mapping a GeoShape field
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      13. Mapping an IP field
        1. Getting ready
        2. How to do it...
        3. How it works...
      14. Mapping an attachment field
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      15. Adding generic data to mapping
        1. Getting ready
        2. How to do it...
        3. How it works...
      16. Mapping different analyzers
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    11. 4. Standard Operations
      1. Introduction
      2. Creating an index
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
      3. Deleting an index
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Opening/closing an index
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Putting a mapping in an index
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Getting a mapping
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Deleting a mapping
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Refreshing an index
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Flushing an index
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Optimizing an index
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
      11. Checking if an index or type exists
        1. Getting ready
        2. How to do it...
        3. How it works...
      12. Managing index settings
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
      13. Using index aliases
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
      14. Indexing a document
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
      15. Getting a document
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
      16. Deleting a document
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      17. Updating a document
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      18. Speeding up atomic operations (bulk)
        1. Getting ready
        2. How to do it...
        3. How it works...
      19. Speeding up GET
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
    12. 5. Search, Queries, and Filters
      1. Introduction
      2. Executing a search
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      3. Sorting a search
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Highlighting results
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Executing a scan query
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Suggesting a correct query
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Counting
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Deleting by query
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Matching all the documents
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Querying/filtering for term
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
      11. Querying/filtering for terms
        1. Getting ready
        2. How to do it...
        3. How it works…
        4. There's more…
        5. See also
      12. Using a prefix query/filter
        1. Getting ready
        2. How to do it...
        3. How it works…
        4. See also
      13. Using a Boolean query/filter
        1. Getting ready
        2. How to do it...
        3. How it works…
        4. See also
      14. Using a range query/filter
        1. Getting ready
        2. How to do it...
        3. How it works...
      15. Using span queries
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      16. Using the match query
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      17. Using the IDS query/filter
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      18. Using the has_child query/filter
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      19. Using the top_children query
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      20. Using the has_parent query/filter
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      21. Using a regexp query/filter
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      22. Using exists and missing filters
        1. Getting ready
        2. How to do it...
        3. How it works...
      23. Using and/or/not filters
        1. Getting ready
        2. How to do it...
        3. How it works...
      24. Using the geo_bounding_box filter
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      25. Using the geo_polygon filter
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      26. Using the geo_distance filter
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
    13. 6. Facets
      1. Introduction
      2. Executing facets
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      3. Executing terms facets
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Executing range facets
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Executing histogram facets
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Executing date histogram facets
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      7. Executing filter/query facets
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Executing statistical facets
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      9. Executing term statistical facets
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Executing geo distance facets
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
    14. 7. Scripting
      1. Introduction
      2. Installing additional script plugins
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Sorting using script
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      4. Computing return fields with scripting
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Filtering a search via scripting
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Updating with scripting
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    15. 8. Rivers
      1. Introduction
      2. Managing a river
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
      3. Using the CouchDB river
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
      4. Using the MongoDB river
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Using the RabbitMQ river
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
      6. Using the JDBC river
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Using the Twitter river
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
    16. 9. Cluster and Nodes Monitoring
      1. Introduction
      2. Controlling cluster health via API
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      3. Controlling cluster state via API
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      4. Getting nodes information via API
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      5. Getting node statistic via API
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      6. Installing and using BigDesk
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
      7. Installing and using ElasticSerach-head
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
      8. Installing and using SemaText SPM
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. See also
    17. 10. Java Integration
      1. Introduction
      2. Creating an HTTP client
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      3. Creating a native client
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Managing indices with the native client
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Managing mappings
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Managing documents
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Managing bulk action
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Creating a query
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      9. Executing a standard search
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Executing a facet search
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      11. Executing a scroll/scan search
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
    18. 11. Python Integration
      1. Introduction
      2. Creating a client
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
      3. Managing indices
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Managing mappings
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
      5. Managing documents
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
      6. Executing a standard search
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
      7. Executing a facet search
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
    19. 12. Plugin Development
      1. Introduction
      2. Creating a site plugin
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
      3. Creating a simple plugin
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      4. Creating a REST plugin
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
      5. Creating a cluster action
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Creating an analyzer plugin
        1. Getting ready
        2. How to do it...
        3. How it works...
      7. Creating a river plugin
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more…
        5. See also
    20. Index