Elasticsearch how to return the number of maching term for each document Elasticsearch how to return the number of maching term for each document elasticsearch elasticsearch

Elasticsearch how to return the number of maching term for each document


For checking a single document, you can retrieve this kind of information using the explain API : http://www.elasticsearch.org/guide/reference/api/explain/

If you need this information collected along with the query results, you can just add the "explain": true to the body sent to the _search. Ex :

{    "explain": true,    "query": {        "term": {           "description": "test"        }    }}

With this parameter, you will get for each hit the associated _explanation data. Ex :

"_explanation": {   "value": 1.4845161,   "description": "fieldWeight(description:test in 63), product of:",   "details": [      {         "value": 1,         "description": "tf(termFreq(description:test)=1)"      },      {         "value": 5.9380646,         "description": "idf(docFreq=23, maxDocs=3348)"      },      {         "value": 0.25,         "description": "fieldNorm(field=description, doc=63)"      }   ]}