# How to score result in elasticsearch?

**URL:** <https://discuss.elastic.co/t/how-to-score-result-in-elasticsearch/34230>\
**Category:** Elasticsearch\
**Created:** [November 10, 2015, 10:21am UTC](https://discuss.elastic.co/t/how-to-score-result-in-elasticsearch/34230 "2015-11-10T10:21:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![NgocPham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ngocpham/32/6242_2.png) [@NgocPham](https://discuss.elastic.co/u/NgocPham)\
**Post date:** [November 10, 2015, 10:21am UTC](https://discuss.elastic.co/t/how-to-score-result-in-elasticsearch/34230/1 "2015-11-10T10:21:32Z")

</div>

sorry for my newbie question, i dont know how elasticsearch score result 😄

i read in [https://www.elastic.co/guide/en/elasticsearch/guide/current/scoring-theory.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/scoring-theory.html) it have :

```
tf(t in d) = √frequency 
idf(t) = 1 + log ( numDocs / (docFreq + 1)) 
norm(d) = 1 / √numTerms  

```

In java, i try search and setExplain(True). My respone is....

```
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 61,
    "max_score" : 2.8814154,
    "hits" : [ {
      "_shard" : 1,
      "_node" : "aJhrjUCeQsWLNYjFTHmufw",
      "_index" : "products",
      "_type" : "product",
      "_id" : "288",
      "_score" : 2.8814154,
      "_source":{"products_id":288,"products_code":"61-65SP287","categories_id":61,"manufacturers_id":65,"users_id":1,"users_fullname":"hong luu","products_title":"Modem Dlink DSL-526E","products_alias":"Modem-Dlink-DSL-526E","products_description":"<table width=\"692\"> \n <tbody> \n <tr> \n <td width=\"177\">Sản phẩm</td> \n <td width=\"515\">Modem</td> \n </tr> \n <tr> \n <td>Hãng sản xuất</td> \n <td>Dlink</td> \n </tr> \n <tr> \n <td>Model</td> \n <td>DSL-526E</td> \n </tr> \n <tr> \n <td>Tốc độ LAN</td> \n <td>10/100Mbps</td> \n </tr> \n <tr> \n <td>Cổng giao tiếp</td> \n <td>1 cổng LAN 10/100Mbps, 1 cổng WAN</td> \n </tr> \n <tr> \n <td>Mô tả khác</td> \n <td>&nbsp;Hỗ trợ dịch vụ myTV, DHCP, NAT, DMZ, Firewall. Hỗ trợ bộ nhớ cao 16MB -&nbsp; tạo 8 kênh riêng ảo (PVC)</td> \n </tr> \n </tbody> \n</table>","seo_keywords":null,"seo_description":null,"seo_title":null,"is_published":1,"is_delete":0,"is_new":false,"is_hot":true,"is_available":true,"date_create":"2015-11-02 21:10:22 +0700","date_update":"2015-11-02 21:10:22 +0700","price":275000,"price_sale":0,"ordering":1,"quantity":10,"thumb_image":"/media/product/13526_16999_0a9ff6cf226e224b7fd33a68943b5cc2.jpg","number_views":0,"vat":10,"rating":0.0,"number_like":0,"total_sale":0,"bao_hanh":24,"product_banner":null,"manufacturers_name":"Dlink","@version":"1","@timestamp":"2015-11-10T03:08:42.205Z"},
      "_explanation" : {
        "value" : 2.8814154,
        "description" : "weight(products_title:dlink in 56) [PerFieldSimilarity], result of:",
        "details" : [ {
          "value" : 2.8814154,
          "description" : "score(doc=56,freq=1.0), product of:",
          "details" : [ {
            "value" : 0.99999994,
            "description" : "queryWeight, product of:",
            "details" : [ {
              "value" : 5.762831,
              "description" : "idf(docFreq=12, maxDocs=1522)"
            }, {
              "value" : 0.17352581,
              "description" : "queryNorm"
            } ]
          }, {
            "value" : 2.8814156,
            "description" : "fieldWeight in 56, product of:",
            "details" : [ {
              "value" : 1.0,
              "description" : "tf(freq=1.0), with freq of:",
              "details" : [ {
                "value" : 1.0,
                "description" : "termFreq=1.0"
              } ]
            }, {
              "value" : 5.762831,
              "description" : "idf(docFreq=12, maxDocs=1522)"
            }, {
              "value" : 0.5,
              "description" : "fieldNorm(doc=56)"
            } ]
          } ]
        } ]
      }
    } 

```

My example have 7620 record , i used plugin [https://github.com/jprante/elasticsearch-index-termlist](https://github.com/jprante/elasticsearch-index-termlist) , it have

```
 "took" : 610,
  "numdocs" : 7620,
  "numterms" : 33407,

```

Who know please explain how to score it 🙂 . Pls show me how it math :X  
Thanks you very much

---

<div class="post-metadata">

**Author:** ![NgocPham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ngocpham/32/6242_2.png) [@NgocPham](https://discuss.elastic.co/u/NgocPham)\
**Post date:** [November 17, 2015, 4:16pm UTC](https://discuss.elastic.co/t/how-to-score-result-in-elasticsearch/34230/2 "2015-11-17T16:16:15Z")

</div>

Anybody please help me know what exactly elasticsearch score T\_T ?

Thanks you

---

<div class="post-metadata">

**Author:** ![tranthanhbao2207](https://avatars.discourse-cdn.com/v4/letter/t/53a042/32.png) [@tranthanhbao2207](https://discuss.elastic.co/u/tranthanhbao2207)\
**Post date:** [November 30, 2015, 8:14am UTC](https://discuss.elastic.co/t/how-to-score-result-in-elasticsearch/34230/3 "2015-11-30T08:14:45Z")

</div>

What do you mean of "score result" exactly, time of searching query or something else ?  
ps: mình cũng mới tình hiểu dc 2 tuần ,~(‾▿‾)~

---

<div class="post-metadata">

**Author:** ![NgocPham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ngocpham/32/6242_2.png) [@NgocPham](https://discuss.elastic.co/u/NgocPham)\
**Post date:** [November 30, 2015, 12:14pm UTC](https://discuss.elastic.co/t/how-to-score-result-in-elasticsearch/34230/4 "2015-11-30T12:14:57Z")

</div>

"exactly" that mean algorithm elasticsearch use for scoring in .setExplain(true) in java.

i use algorithm write in guide elasticsearch, but it not true with my example. i dont know how it work

Thus, i want anybody know that please explain to me " How elasticsearch Scoring " in my example (or any example its ok, i only want know how it working,what is numDocs, docFreq in .setExplain(true) ).

Thanks for your help !

p/s: You can pm me if want speak our language @tranthanhbao2207 :))

---

<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 5, 2017, 11:34pm UTC](https://discuss.elastic.co/t/how-to-score-result-in-elasticsearch/34230/5 "2017-07-05T23:34:52Z")

</div>


