Score of a Query

Hi,

Is there anyway I can ask for the score of each document returned to
be added to the results in a query, I'm finding it hard to debug the
ordering of my results.

Best Regards,

David.

You should use the explain parameter (
http://www.elasticsearch.org/guide/reference/api/search/explain.html). This
will display score for each result and a detailed explanation of the score
computation.

Unless I am misunderstanding the question, this comes back in the
result JSON as:
hits.hits[n]._score

If relevancy based scoring isn't used, this comes back as null.

On Jul 27, 10:38 am, davrob2 davirobe...@gmail.com wrote:

Hi,

Is there anyway I can ask for the score of each document returned to
be added to the results in a query, I'm finding it hard to debug the
ordering of my results.

Best Regards,

David.

Hi David

Is there anyway I can ask for the score of each document returned to
be added to the results in a query, I'm finding it hard to debug the
ordering of my results.

It is added to each result, unless you're sorting by something other
than _score

clint

On a side note if you are sorting by something other than _score you should
have a look to the track_scores parameter.

Hi Guys,

Thanks for your answers. This is what I have managed to get done so
far:

i) The equivalent of setting explain: true in the url params is to
setExplain(true) on the SearchRequestIndexBuilder

ii) When I set explain true, this is a sample of what I get from
SearchHit.explanation().toString():

1.2891362 = weight(listIds:6836 in 796), product of:
0.99999994 = queryWeight(listIds:6836), product of:
10.31309 = idf(docFreq=6, maxDocs=77575)
0.09696414 = queryNorm
1.2891363 = fieldWeight(listIds:6836 in 796), product of:
1.0 = tf(termFreq(listIds:6836)=1)
10.31309 = idf(docFreq=6, maxDocs=77575)
0.125 = fieldNorm(field=listIds, doc=796)

A guide of what the above means would be really useful.

i.e. What is "idf" / doc frequency referring to?
What is "queryNorm", "fieldWeight", "tf"/term frequency and
"fieldNorm"?

iii) Whether I set explain(true) or not score() method on SearchHit
always return NaN:

for (SearchHit hit : queryResponse.getHits()){
Map<String, Object> source = hit.getSource();
source.put("score", hit.score());
...
}

I think this is fine for me, to set explain(true) when I need to debug
my results.

cheers,

David.

On Jul 27, 6:03 pm, Benjamin Devèze benjamin.dev...@gmail.com wrote:

On a side note if you are sorting by something other than _score you should
have a look to the track_scores parameter.

You might not be getting the score itself because you are sorting on a
field? If you still want the score (without running explain, which is
expensive), then you can set track scores to true (
Elasticsearch Platform — Find real-time answers at scale | Elastic), in the
Java API, you simply set SearchRequestBuilder#setTrackScores in order to get
scores back even though you are not sorting on them.

On Mon, Aug 1, 2011 at 2:51 PM, davrob2 daviroberts@gmail.com wrote:

Hi Guys,

Thanks for your answers. This is what I have managed to get done so
far:

i) The equivalent of setting explain: true in the url params is to
setExplain(true) on the SearchRequestIndexBuilder

ii) When I set explain true, this is a sample of what I get from
SearchHit.explanation().toString():

1.2891362 = weight(listIds:6836 in 796), product of:
0.99999994 = queryWeight(listIds:6836), product of:
10.31309 = idf(docFreq=6, maxDocs=77575)
0.09696414 = queryNorm
1.2891363 = fieldWeight(listIds:6836 in 796), product of:
1.0 = tf(termFreq(listIds:6836)=1)
10.31309 = idf(docFreq=6, maxDocs=77575)
0.125 = fieldNorm(field=listIds, doc=796)

A guide of what the above means would be really useful.

i.e. What is "idf" / doc frequency referring to?
What is "queryNorm", "fieldWeight", "tf"/term frequency and
"fieldNorm"?

iii) Whether I set explain(true) or not score() method on SearchHit
always return NaN:

for (SearchHit hit : queryResponse.getHits()){
Map<String, Object> source = hit.getSource();
source.put("score", hit.score());
...
}

I think this is fine for me, to set explain(true) when I need to debug
my results.

cheers,

David.

On Jul 27, 6:03 pm, Benjamin Devèze benjamin.dev...@gmail.com wrote:

On a side note if you are sorting by something other than _score you
should
have a look to the track_scores parameter.