Function score query with decay function on huge dataset

Good day everyone.


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.


I have generated a sample data with 10k products, each product has 10k to 100k sellers to test. It returned result after 24 seconds.


  • 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!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.