Indexing data that is not flat
Not all data is flat like the examples we have used in the book until now. Most of the data you will encounter will have some structure and nested objects inside the root JSON object. Of course, if we are building our system that Elasticsearch will be a part of and we are in control of all the pieces of it, we can create a structure that is convenient for Elasticsearch. But even in such cases, flat data is not always an option. Thankfully, Elasticsearch allows us to index data that is not flat and this section will show us how to do that.
Data
Let's assume that we have the following data (we store it in the file called structured_data.json
):
{ "author" : { "name" : { "firstName" : "Fyodor", "lastName" : "Dostoevsky" } }, "isbn" : "123456789", "englishTitle" : "Crime and Punishment", "year" : 1886, "characters" : [ { "name" : "Raskolnikov" }, { "name" : "Sofia" } ], "copies" : 0 }
As you can see the...