I have 2 entities stored in separate indexes:
City
index has 2 fields mapping:name:keyword
andurl:text
.Product
index has 2 fields mapping:name:keyword
andcity:text
I would like to query all Product
s by City
's url.
Example:
Given: Search all shirts by url "http://shirts-shop.com/frankfurt"
Then (step 1): Search all cities where url is "http://shirts-shop.com/frankfurt" — it will return "Frankfurt" city
Then (step 2): Search all shirts by city "Frankfurt"
In SQL databases it is quite simple to write: we just need to use 'join' query. How to write such query in ElasticSearch 6.5 ?
WARN: Entities are in separate indexes, because as said in documentation ElasticSearch starting from version 6 recommends to use 1 index per mapping.