# Too much time spending on build\_scorer in elasticsearch queries

**URL:** <https://discuss.elastic.co/t/too-much-time-spending-on-build-scorer-in-elasticsearch-queries/368825>\
**Category:** Elasticsearch\
**Created:** [October 15, 2024, 7:52am UTC](https://discuss.elastic.co/t/too-much-time-spending-on-build-scorer-in-elasticsearch-queries/368825 "2024-10-15T07:52:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chanaka\_Liyanarachch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chanaka_liyanarachch/32/97624_2.png) [@Chanaka\_Liyanarachch](https://discuss.elastic.co/u/Chanaka_Liyanarachch)\
**Post date:** [October 15, 2024, 7:52am UTC](https://discuss.elastic.co/t/too-much-time-spending-on-build-scorer-in-elasticsearch-queries/368825/1 "2024-10-15T07:52:04Z")

</div>

Too much time spending on calculating the score in the below queries, I have only used the filters but still, it's calculates the score,

Query:-

```auto
{
  "from": 0,
  "size": 10,
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "accountingPeriod": {
              "from": null,
              "to": "2024_08",
              "include_lower": true,
              "include_upper": true,
              "boost": 1
            }
          }
        },
        {
          "term": {
            "stakeholderId": {
              "value": "customer",
              "boost": 1
            }
          }
        },
        {
          "term": {
            "currencyTypeId": {
              "value": "points",
              "boost": 1
            }
          }
        },
        {
          "term": {
            "accountReferenceId": {
              "value": "3378295",
              "boost": 1
            }
          }
        },
        {
          "bool": {
            "must_not": [
              {
                "bool": {
                  "must": [
                    {
                      "term": {
                        "accountingYear": {
                          "value": 2024,
                          "boost": 1
                        }
                      }
                    },
                    {
                      "term": {
                        "accountingMonth": {
                          "value": 10,
                          "boost": 1
                        }
                      }
                    }
                  ],
                  "adjust_pure_negative": true,
                  "boost": 1
                }
              }
            ]
          }
        }
      ],
      "adjust_pure_negative": true,
      "boost": 1
    }
  },
  "sort": [
    "_doc"
  ],
  "_source": {
    "includes": [],
    "excludes": []
  },
  "track_total_hits": 2147483647,
  "aggregations": {
    "t1": {
      "terms": {
        "field": "accountId.keyword",
        "size": 10,
        "min_doc_count": 1,
        "shard_min_doc_count": 0,
        "show_term_doc_count_error": false,
        "order": [
          {
            "_count": "desc"
          },
          {
            "_key": "asc"
          }
        ]
      },
      "aggregations": {
        "t2": {
          "terms": {
            "field": "currencyTypeId.keyword",
            "size": 10,
            "min_doc_count": 1,
            "shard_min_doc_count": 0,
            "show_term_doc_count_error": false,
            "order": [
              {
                "_count": "desc"
              },
              {
                "_key": "asc"
              }
            ]
          },
          "aggregations": {
            "t3": {
              "terms": {
                "field": "stakeholderId.keyword",
                "size": 10,
                "min_doc_count": 1,
                "shard_min_doc_count": 0,
                "show_term_doc_count_error": false,
                "order": [
                  {
                    "_count": "desc"
                  },
                  {
                    "_key": "asc"
                  }
                ]
              },
              "aggregations": {
                "sum_amount": {
                  "sum": {
                    "field": "balance"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

```

Query profile:-

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/f/6fd5b5284987bc699d42d7c9d20537e6291025c7.png)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/c/0c206b0de127cca4a27ba95a775afdca4664fe60.png)
