Dear Eleasticsearch team,
My team is facing an interesting situation. There are two web services - "Account" and "Membership". "Account" service stores customers' names, gender, date_of_birth, etc. "Membership" service stores which product plan customers have subscribed. Both of them plan to use Elasticsearch to provide searching function.
For some reasons, we could not merge these two services (or their data models) together. We can only design how to create index, define index mapping, and build search query.
One idea is each service has its own index. Then each index's mapping can perfectly match each service's data model. And searching query will be simple and straightforward.
But there is only one searching UI. Again my team cannot change it either. For example, admins can search on "first_name = Tom AND plan = Apple Mobile". It will generate two different searching queries on two indices. We can return the inner set of two searching results. But if we want to provide features like pagination, it will be quite difficult.
Could we apply different queries on different indices, but Elasticsearch returns one result? The "customer_id" is the common field of documents in two indices. For example,
(POST) /account,membership/doc/_search?size=50
{
"query": [
{
"index": "account",
"query_string": {
"query": "first_name: will AND gender: male"
}
},
{
"index": "membership",
"query_string": {
"query": "plan: Apple Mobile"
}
}
]
}
I know the above example does not match your syntax. I just use it to describe my question.
Another solution is merging two indices into one indices. Then we could simply rely on Elasticsearch built-in searching feature and scoring mechanism.
But we still would like to try a bit more with two indices, separate search and merge/aggregate two searching results within Elasticsearch.
Sorry for a long message.
Regards!