I have a parent - child relationship in my Elastic Search mappings, and they look like follows. There is an "abstract" entity of type user and both driver and passenger inherit from it.
Now I am able to search within any of those indices, for example I can search the driver index like this: GET /driver/.
However, if I search GET /user/, I would expect to see records from both the driver and the passenger indices (since they inherit from the user), but I am getting an empty result. Although the records in the derived indices do exist.
Is there any way I could get all the indices that inherit from the parent?
There is nothing like inheritance in elasticsearch. You need to implement that by yourself.
Probably by duplicating data. Why would you need to use parent/child by the way?
@dadoonet
Probably I misunderstood the concept there, but my requirement is to be able to search through different types in a single query. For example, I have a type Driver and a type Passenger, and I want to query for all Users (Drivers or Passengers) that have been registered after some specific date. Additionally, I need to be able to query within a single type - for example query all Drivers whose car is BMW. What would be the correct design for such requirements then?
@dadoonet
Yeah, that's completely fine, however querying across multiple indices is what is bothering me. What would be the way to query both of those indices per "firstName"?... which would then retrieve me both the Drivers and Passengers whose name is Bob. That's the question.
@dadoonet
Which one of the two approaches would yield better performances?
Additionally, what would the query for multiple indices look like? I tried to search the docs, but couldn't find the example that does something similar.
The part where you wrote "// Your query here". Example if we search for users with name Bob.
The less shards you hit the better.
So if you can fit all your data within one single index with one shard, it will be faster than 2 indices with 1 shard each.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.