Wednesday 11 November 2015

Elasticsearch: how “_score” is calculated


Elastic search gives explanation for you, how it calculated “_score” value. You just pass query parameter “explain” to the search URL, elastic search provides “_explanation” field in the result, that gives detailed explanation, how “_score” value calculated.
GET books/philosophy/_search?explain
{
  "query":{
    "match": {
      "description": "religious"
    }
  }
}

Response like below.

{
   "took": 3,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 2,
      "max_score": 0.125,
      "hits": [
         {
            "_shard": 2,
            "_node": "p1jQi2o8RZmOwEFlD4qQwQ",
            "_index": "books",
            "_type": "philosophy",
            "_id": "1",
            "_score": 0.125,
            "_source": {
               "pages": 1152,
               "title": "The Book of Secrets",
               "description": "These techniques will not mention any religious ritual. No temple is needed, you are quite enough of a temple yourself. You are the lab; the whole experiment is to go on within you. This is not religion, this is science. No belief is needed. Only a daringness to experiment is enough; courage to experiment is enough.",
               "ISBN": "0312180586",
               "publisher": "St. Martin's Griffin",
               "author": {
                  "firstName": "Osho",
                  "lastName": "Chandra Mohan Jain"
               },
               "price": 1500,
               "tags": [
                  "Spiritual",
                  "Philosophy",
                  "secrets"
               ]
            },
            "_explanation": {
               "value": 0.125,
               "description": "weight(description:religious in 0) [PerFieldSimilarity], result of:",
               "details": [
                  {
                     "value": 0.125,
                     "description": "fieldWeight in 0, product of:",
                     "details": [
                        {
                           "value": 1,
                           "description": "tf(freq=1.0), with freq of:",
                           "details": [
                              {
                                 "value": 1,
                                 "description": "termFreq=1.0"
                              }
                           ]
                        },
                        {
                           "value": 1,
                           "description": "idf(docFreq=1, maxDocs=2)"
                        },
                        {
                           "value": 0.125,
                           "description": "fieldNorm(doc=0)"
                        }
                     ]
                  }
               ]
            }
         },
         {
            "_shard": 4,
            "_node": "p1jQi2o8RZmOwEFlD4qQwQ",
            "_index": "books",
            "_type": "philosophy",
            "_id": "3",
            "_score": 0.033562027,
            "_source": {
               "pages": 152,
               "title": "Emotions: Freedom from Anger, Jealousy and Fear",
               "description": "I'm not a Buddhist, but a Christian. I started reading, just to see what it was about and read the whole thing. The beginning is a very relaxing read and had some highlightable/clipable quotes. I do have different religious beliefs, this book offered some areas for further prayer and contemplation but I did not find these areas offensive so much as a beneficial exposure to a different perspective",
               "ISBN": "1938755928",
               "publisher": " Osho Media International",
               "author": {
                  "firstName": "Osho",
                  "lastName": "Chandra Mohan Jain"
               },
               "price": 400,
               "tags": [
                  "Spiritual",
                  "Philosophy",
                  "emotions",
                  "freedom",
                  "angry",
                  "Jealousy",
                  "Fear"
               ]
            },
            "_explanation": {
               "value": 0.033562027,
               "description": "weight(description:religious in 0) [PerFieldSimilarity], result of:",
               "details": [
                  {
                     "value": 0.033562027,
                     "description": "fieldWeight in 0, product of:",
                     "details": [
                        {
                           "value": 1,
                           "description": "tf(freq=1.0), with freq of:",
                           "details": [
                              {
                                 "value": 1,
                                 "description": "termFreq=1.0"
                              }
                           ]
                        },
                        {
                           "value": 0.30685282,
                           "description": "idf(docFreq=1, maxDocs=1)"
                        },
                        {
                           "value": 0.109375,
                           "description": "fieldNorm(doc=0)"
                        }
                     ]
                  }
               ]
            }
         }
      ]
   }
}



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment