Good day everyone.
Background
I'm building a search engine for a marketplace. Our market has products, sellers, and customers. Each product has many sellers with their locations. The number of sellers might be around 100k. I store seller's locations in each products (nested field and parent-child don't meet up my requirements), for e.g:
{
"mappings": {
"properties": {
"stores": {
"location": {
"type": "geo_point"
}
}
}
}
}
When searching for products, I use function score query with decay function to re-ranking based on the distance from customer to seller's locations. score_mode
is also set to max
to rescore with closest sellers.
Problem
I have generated a sample data with 10k products, each product has 10k to 100k sellers to test. It returned result after 24 seconds.
Question
- Is there any way to improve this function score query?
- In case there is no way to improve, what is the practical way to do for my use case?
Thank you very much!