# BM25: How not to add up document lengths for each element in array field

**URL:** <https://discuss.elastic.co/t/bm25-how-not-to-add-up-document-lengths-for-each-element-in-array-field/382184>\
**Category:** Elastic Search\
**Created:** [September 24, 2025, 7:59am UTC](https://discuss.elastic.co/t/bm25-how-not-to-add-up-document-lengths-for-each-element-in-array-field/382184 "2025-09-24T07:59:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jorgenfu](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jorgenfu](https://discuss.elastic.co/u/jorgenfu)\
**Post date:** [September 24, 2025, 7:59am UTC](https://discuss.elastic.co/t/bm25-how-not-to-add-up-document-lengths-for-each-element-in-array-field/382184/1 "2025-09-24T07:59:22Z")

</div>

One of the fields in our search is an array of person names. We see that when searching for a the name of a single person, documents with several people attached score lower. From what I can tell this is because the document length dl in the BM25 algorithm is accumulated over the whole list of people.

Is there a way not to score documents with several people lower? For now my only idea is to set b=0 for the person field and so discount document length altogether, although I expect this not to be ideal – we’d still like to take into account document length within each person name.

Note that our full search is a bool search with several multimatch queries etc, but the behaviour described above is retained when paring it down to searching the person field only.

---

<div class="post-metadata">

**Author:** ![Kathleen\_DeRusso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kathleen_derusso/32/132039_2.png) [@Kathleen\_DeRusso](https://discuss.elastic.co/u/Kathleen_DeRusso)\
**Post date:** [September 24, 2025, 12:51pm UTC](https://discuss.elastic.co/t/bm25-how-not-to-add-up-document-lengths-for-each-element-in-array-field/382184/2 "2025-09-24T12:51:37Z")

</div>

You could consider modeling your person field as a [nested](https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/nested) field, which would probably get you what you want scoring but increase query complexity.

You could also look at a [function\_score](https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-function-score-query) query.
