You are previewing ElasticSearch Cookbook - Second Edition.
O'Reilly logo
ElasticSearch Cookbook - Second Edition

Book Description

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

In Detail

This book will guide you through the complete ElasticSearch ecosystem. From choosing the correct transport layer and communicating with the server to creating and customizing internal actions, you will develop an in-depth knowledge of the implementation of the ElasticSearch architecture.

After creating complex queries and analytics, mapping, aggregation, and scripting, you will master the integration of ElasticSearch's functionality in user-facing applications and take your knowledge one-step further by building custom plugins, developing tailored mapping, executing powerful analytics, and integrating with Python and Java applications.

What You Will Learn

  • Make ElasticSearch work for you by choosing the best cloud topology and powering it with plugins

  • Develop tailored mapping to take full control of index steps

  • Build complex queries through managing indices and documents

  • Optimize search results through executing analytics aggregations

  • Manage rivers (SQL, NoSQL, and web-based) to synchronize and populate cross-source data

  • Develop web interfaces to execute key tasks

  • Monitor the performance of the cluster and nodes

  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. ElasticSearch Cookbook Second Edition
      1. Table of Contents
      2. ElasticSearch Cookbook Second Edition
      3. Credits
      4. About the Author
      5. Acknowledgments
      6. About the Reviewers
      7. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      8. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Sections
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Conventions
        6. Reader feedback
        7. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      9. 1. Getting Started
        1. Introduction
        2. Understanding nodes and clusters
          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 practices
          4. See also
        5. Understanding clusters, replication, and sharding
          1. Getting ready
          2. How it works...
          3. There's more...
            1. Solving the yellow status...
            2. Solving the red status
          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. There's more...
          4. See also
      10. 2. Downloading and Setting Up
        1. Introduction
        2. Downloading and installing ElasticSearch
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. There's more...
        3. Setting up networking
          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 for Linux systems
          1. Getting ready
          2. How to do it...
          3. How it works...
        6. Setting up different node types
          1. Getting ready
          2. How to do it...
          3. How it works...
        7. Installing plugins in ElasticSearch
          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
          1. Getting ready
          2. How to do it...
          3. How it works...
      11. 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...
          5. See also
        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. Adding a field with multiple mappings
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        11. Mapping a geo point field
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        12. Mapping a geo shape 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 metadata to a mapping
          1. Getting ready
          2. How to do it...
          3. How it works...
        16. Specifying a different analyzer
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        17. Mapping a completion suggester
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
      12. 4. Basic 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 is 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 operations)
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        19. Speeding up GET operations (multi GET)
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also...
      13. 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 results
          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 matched results
          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 a single term
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        11. Querying/filtering for multiple 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...
          4. There's more...
        15. Using span queries
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        16. Using a match query
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        17. Using an ID query/filter
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        18. Using a has_child query/filter
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        19. Using a top_children query
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        20. Using a 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 a function score query
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        23. Using exists and missing filters
          1. Getting ready
          2. How to do it...
          3. How it works...
        24. Using and/or/not filters
          1. Getting ready
          2. How to do it...
          3. How it works...
        25. Using a geo bounding box filter
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        26. Using a geo polygon filter
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        27. Using geo distance filter
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        28. Using a QueryString query
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        29. Using a template query
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      14. 6. Aggregations
        1. Introduction
        2. Executing an aggregation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        3. Executing the stats aggregation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        4. Executing the terms aggregation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
          5. See also
        5. Executing the range aggregation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
          5. See also
        6. Executing the histogram aggregation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
          5. See also
        7. Executing the date histogram aggregation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        8. Executing the filter aggregation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
          5. See also
        9. Executing the global aggregation
          1. Getting ready
          2. How to do it...
          3. How it works...
        10. Executing the geo distance aggregation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        11. Executing nested aggregation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
        12. Executing the top hit aggregation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See Also
      15. 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. Managing scripts
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        4. Sorting data using script
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Computing return fields with scripting
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        6. Filtering a search via scripting
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Updating a document using scripts
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      16. 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. There's more...
          5. 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
      17. 9. Cluster and Node Monitoring
        1. Introduction
        2. Controlling cluster health via the 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 the API
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Getting cluster node information via the API
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
          5. See also
        5. Getting node statistics via the API
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
          5. See also
        6. Managing repositories
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
          5. See also
        7. Executing a snapshot
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
        8. Restoring a snapshot
          1. Getting ready
          2. How to do it...
          3. How it works...
        9. Installing and using BigDesk
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
        10. Installing and using ElasticSearch Head
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
        11. Installing and using SemaText SPM
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        12. Installing and using Marvel
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
      18. 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 actions
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        8. Building 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 search with aggregations
          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
      19. 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 search with aggregations
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
          5. See also
      20. 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 native 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
      21. Index