# Relevancy - how this is calculated

**URL:** https://discuss.elastic.co/t/relevancy-how-this-is-calculated/238504
**Category:** Elasticsearch
**Created:** [June 24, 2020, 2:42pm UTC](https://discuss.elastic.co/t/relevancy-how-this-is-calculated/238504 "2020-06-24T14:42:05Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nages](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nages/32/46943_2.png) [@nages](https://discuss.elastic.co/u/nages)
#### Post date: [June 24, 2020, 2:42pm UTC](https://discuss.elastic.co/t/relevancy-how-this-is-calculated/238504/1 "2020-06-24T14:42:06Z")

</div>

I had the following documents indexed

```
PUT ecommercesite/product/2
{
   "product_name": "Men Water Resistant Jacket",
   "description": "Provides comfort during biking and hiking",
 } 

```

when I tried to get the scoring for this document for a query

```
    POST ecommercesite/product/2/_explain
    {
     
      "query":{
        "bool" : {
          "should": [
            {
              "match": {
                "product_name": "Performance Fleece"
              }
            },
            {
              "bool": {
                "must": [
                  {
                    "match": {
                      "product_name": "Water resistant"
                    }
                  },
                  {
                    "range": {
                      "unit_price": {
                        "lte": 100
                      }
                    }
                  }
                  
                ]
              }
            }
          ]
        }
      }
    }

The scoring looks like this ,

{
  "_index" : "ecommercesite",
  "_type" : "product",
  "_id" : "2",
  "matched" : true,
  "explanation" : {
    "value" : 1.5753641,
    "description" : "sum of:",
    "details" : [
      {
        "value" : 1.5753641,
        "description" : "sum of:",
        "details" : [
          {
            "value" : 0.5753642,
            "description" : "sum of:",
            "details" : [
              {
                "value" : 0.2876821,
                "description" : "weight(product_name:water in 0) [PerFieldSimilarity], result of:",
                "details" : [
                  {
                    "value" : 0.2876821,
                    "description" : "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
                    "details" : [
                      {
                        "value" : 0.2876821,
                        "description" : "idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:",
                        "details" : [
                          {
                            "value" : 1.0,
                            "description" : "docFreq",
                            "details" : []
                          },
                          {
                            "value" : 1.0,
                            "description" : "docCount",
                            "details" : []
                          }
                        ]
                      },
                      {
                        "value" : 1.0,
                        "description" : "tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength / avgFieldLength)) from:",
                        "details" : [
                          {
                            "value" : 1.0,
                            "description" : "termFreq=1.0",
                            "details" : []
                          },
                          {
                            "value" : 1.2,
                            "description" : "parameter k1",
                            "details" : []
                          },
                          {
                            "value" : 0.75,
                            "description" : "parameter b",
                            "details" : []
                          },
                          {
                            "value" : 4.0,
                            "description" : "avgFieldLength",
                            "details" : []
                          },
                          {
                            "value" : 4.0,
                            "description" : "fieldLength",
                            "details" : []
                          }
                        ]
                      }
                    ]
                  }
                ]
              },
              {
                "value" : 0.2876821,
                "description" : "weight(product_name:resistant in 0) [PerFieldSimilarity], result of:",
                "details" : [
                  {
                    "value" : 0.2876821,
                    "description" : "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
                    "details" : [
                      {
                        "value" : 0.2876821,
                        "description" : "idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:",
                        "details" : [
                          {
                            "value" : 1.0,
                            "description" : "docFreq",
                            "details" : []
                          },
                          {
                            "value" : 1.0,
                            "description" : "docCount",
                            "details" : []
                          }
                        ]
                      },
                      {
                        "value" : 1.0,
                        "description" : "tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength / avgFieldLength)) from:",
                        "details" : [
                          {
                            "value" : 1.0,
                            "description" : "termFreq=1.0",
                            "details" : []
                          },
                          {
                            "value" : 1.2,
                            "description" : "parameter k1",
                            "details" : []
                          },
                          {
                            "value" : 0.75,
                            "description" : "parameter b",
                            "details" : []
                          },
                          {
                            "value" : 4.0,
                            "description" : "avgFieldLength",
                            "details" : []
                          },
                          {
                            "value" : 4.0,
                            "description" : "fieldLength",
                            "details" : []
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "value" : 1.0,
            "description" : "unit_price:[-2139095041 TO 1120403456]",
            "details" : []
          }
        ]
      }
    ]
  }
}

```

what I really didnt understand was, if we look at "sum of " block - it is only considering the query ""product\_name": "Water resistant"" as you see there in the output - Why is it so, where does it calculate the scoring for ""product\_name": "Performance Fleece"

I am on 6.8.8

---

<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: [July 22, 2020, 2:42pm UTC](https://discuss.elastic.co/t/relevancy-how-this-is-calculated/238504/2 "2020-07-22T14:42:06Z")

</div>

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