Chapter 16. Python Integration

In this chapter, we will cover the following recipes:

  • Creating a client
  • Managing indices
  • Managing mappings
  • Managing documents
  • Executing a standard search
  • Executing a search with aggregations

Introduction

In the previous chapter, we saw how it is possible to use a native client to access the Elasticsearch server via Java. This chapter is dedicated to the Python language and how to manage common tasks via its clients.

Apart from Java, the Elasticsearch team supports official clients for Perl, PHP, Python, .NET, and, Ruby. (See the announcement post on the Elasticsearch blog at http://www.elasticsearch.org/blog/unleash-the-clients-ruby-python-php-perl/.) These clients have a lot of advantages over other implementations. A few of them are mentioned as follows:

  • They are strongly tied to the Elasticsearch API:

                 "These clients are direct translations of the native Elasticsearch REST interface"                                                                                                     - The Elasticsearch team

  • They handle dynamic node detection and failover: they are built with a strong networking base for communicating with the cluster.
  • They have full coverage of the REST API. They share the same application approach for every language in which they are available, so switching from one language to another is fast.
  • They are easily extensible.

The Python client plays very well with other Python frameworks such as Django, web2py, and Pyramid. It allows very fast access to documents, indices, and clusters.

In this chapter, I'll try to describe the most important functionalities of the Elasticsearch official Python client; for additional examples, I suggest you to take a look at the online GitHub repository and documentation at the following URL: https://github.com/elastic/elasticsearch-py.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.57.219