Delay in response after using function_score for sorting of documents according to field match

When using function_score to sort the document on base of score response is taking too much time to come it's in minutes. The problem is I need sorting according to fields. When using boost not getting the relevant data.

query I'm using is as follow:

function_score.functions[
/********* registered indian user exact match ********/
        {
          "filter": {
            "bool": {
              "must": [
                {
                  "exists": {
                    "field": "userId"
                  }
                },
                {
                  "exists": {
                    "field": "location.country"
                  }
                },
                {
                  "match": {
                    "location.country.name": "india"
                  }
                },
                {
                  "wildcard": {
                    "keywords.keyword": `${p}`
                  }
                }
              ]
            }
          },
          "weight": 10
        },
        /********* registered indian user partial match ********/
        {
          "filter": {
            "bool": {
              "must": [
                {
                  "exists": {
                    "field": "userId"
                  }
                },
                {
                  "exists": {
                    "field": "location.country"
                  }
                },
                {
                  "match": {
                    "location.country.name": "india"
                  }
                },
                {
                  "wildcard": {
                    "keywords.keyword": `*${p}*`
                  }
                }
              ]
            }
          },
          "weight": 15
        },

        /********* registered foreign user exact match ********/
        {
          "filter": {
            "bool": {
              "must": [
                {
                  "exists": {
                    "field": "userId"
                  }
                },
                {
                  "exists": {
                    "field": "location.country"
                  }
                },
                {
                  "wildcard": {
                    "keywords.keyword": `${p}`
                  }
                }
              ],
              "must_not": [
                {
                  "match": {
                    "location.country.name": "india"
                  }
                }
              ]
            }
          },
          "weight": 20
        },
        /********* registered foreign user partial match ********/
        {
          "filter": {
            "bool": {
              "must": [
                {
                  "exists": {
                    "field": "userId"
                  }
                },
                {
                  "exists": {
                    "field": "location.country"
                  }
                },
                {
                  "wildcard": {
                    "keywords.keyword": `*${p}*`
                  }
                }
              ],
              "must_not": [
                {
                  "match": {
                    "location.country.name": "india"
                  }
                }
              ]
            }
          },
          "weight": 25
        },


        /********* not registered india user exact match ********/
        {
          "filter": {
            "bool": {
              "must": [
                // {
                //   "exists": {
                //     "field": "location.country"
                //   }
                // },
                {
                  "match": {
                    "location.country.name": "india"
                  }
                },
                {
                  "wildcard": {
                    "keywords.keyword": `${p}`
                  }
                }
              ]
            }
          },
          "weight": 45
        },
        /********* not registered india user partial match ********/
        {
          "filter": {
            "bool": {
              "must": [
                // {
                //   "exists": {
                //     "field": "location.country"
                //   }
                // },
                {
                  "match": {
                    "location.country.name": "india"
                  }
                },
                {
                  "wildcard": {
                    "keywords.keyword": `*${p}*`
                  }
                }
              ]
            }
          },
          "weight": 50
        },
        
        ********* not registered foreign user exact match ********/
        {
          "filter": {
            "bool": {
              "must": [
                {
                  "wildcard": {
                    "keywords.keyword": `${p}`
                  }
                }
              ],
              "must_not": [
                {
                  "match": {
                    "location.country.name": "india"
                  }
                }
              ]
            }
          },
          "weight": 55
        },
       /********* not registered foreign user partial match ********/
        {
          "filter": {
            "bool": {
              "must": [
                {
                  "wildcard": {
                    "keywords.keyword": `*${p}*`
                  }
                }
              ],
              "must_not": [
               {
                  "match": {
                    "location.country.name": "india"
                  }
                }
              ]
            }
          },
          "weight": 60
        }
    ]

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