# Compound score computation details

**URL:** <https://discuss.elastic.co/t/compound-score-computation-details/302940>\
**Category:** Elasticsearch\
**Created:** [April 21, 2022, 3:48pm UTC](https://discuss.elastic.co/t/compound-score-computation-details/302940 "2022-04-21T15:48:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![med\_rgn](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@med\_rgn](https://discuss.elastic.co/u/med_rgn)\
**Post date:** [April 21, 2022, 3:48pm UTC](https://discuss.elastic.co/t/compound-score-computation-details/302940/1 "2022-04-21T15:48:25Z")

</div>

Hello

_context_  
In my use case I rank documents regarding an input request relying on a compound score used for the ranking. This compound score is a weighted sum of 3 text similarity scores as follow:  
`score = weight1 * score1 + weight2 * score2 + weight3 * score3`.

Each score relates to a given text field and similarity defined in the index mapping, for instance:

```auto
{
    "settings": {
           "similarity": {"text_similarity":{}} # not detailed here
     },
     "mappings": {
          "properties": {
                "text1": {
                    "type": "text",
                    "similarity": "text_similarity",
                }
          }
         # same for text2 and text3
     }
}

```

On the query side, I have a function score for each score, for instance:

```auto
{
    "query": {
         "bool": {
             "should": [
                     {
                          "function_score": {
                               "query": {"match" : {"text1": request_text1}},
                               "boost": weight1
                     }
                     # function score text2
                     # function score text3
              ]
        }
    }
}

```

_Problem_  
My goal is to have **the detail of each score** beside the final compound score.  
I am aware of explain API, however the order of the 3 function scores in the `explanation` changes which makes difficult to associate a given value to a score.  
Moreover the explain API impacts significantly the query time.

Is there a better way to obtain the detail of each score? Am I missing something?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 19, 2022, 3:49pm UTC](https://discuss.elastic.co/t/compound-score-computation-details/302940/2 "2022-05-19T15:49:25Z")

</div>

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