Toute — An ElasticSearch Object Document Mapper (ODM) was born!
‘Toute’ is an ElasticSearch ODM based on ESEngine (fork).
The name came from my love for Toute, It means berries in arabic.
ElasticSearch Documents can be saved and searched through python objects easily, in this tutorial I will go through the main functionalities and how to achieve them using Toute.
This article will be divided into the following sections:
- Schema Design & Implementation
- Quering
- Custom Queries
Object Relational Mapping
Object-relational mapping in computer science is a programming technique for converting data between incompatible type systems using object-oriented programming languages. This creates, in effect, a “virtual object database” that can be used from within the programming language.
Schema Design
Our Schema contains the main entity which is ‘Song’, and 2 sub documents ‘album’ and ‘Artist’ like shown on the figure.
First we start with making a connection to elastic search
We will create a client factory for our client as follows:
Defining Documents
we will define our song document to be indexed, the index name is shown in the _index field, and the doc type we will be using is song
The following types are currently supported
Let’s go ahead and define our song document
Indexing a new document (a song)
We’re going to be using this song called Sour from Void Vision
Querying
Here we will query elastic search using different ways, first let’s look at the filter method and what it can do for us.
For instance let’s say we want to search for songs in by name
What about performing complex elastic search queries ? We got it covered…
Custom Elastic Search Queries
References:
To be continued….