# Why i am not getting any score in SearchRequestBuilder after sorting?

**URL:** <https://discuss.elastic.co/t/why-i-am-not-getting-any-score-in-searchrequestbuilder-after-sorting/7043>\
**Category:** Elasticsearch\
**Created:** [March 18, 2012, 3:15pm UTC](https://discuss.elastic.co/t/why-i-am-not-getting-any-score-in-searchrequestbuilder-after-sorting/7043 "2012-03-18T15:15:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohitkondekar](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@rohitkondekar](https://discuss.elastic.co/u/rohitkondekar)\
**Post date:** [March 18, 2012, 3:15pm UTC](https://discuss.elastic.co/t/why-i-am-not-getting-any-score-in-searchrequestbuilder-after-sorting/7043/1 "2012-03-18T15:15:43Z")

</div>

Hello everyone,

I just got my hands on elasticsearch yesterday, because we had a requirement of evaluating complex mathematical queries for comparison like "evaluating eculadian distances" rather than simple text matching.  
I read that in elasticsearch, we can execute scripts as well as native (java) scripts for evaluating custom scores.

So my first question was 1. what is the score exactly? and how is it evaluated?  
2. when i am using SearchRequestBuilder (in JAVA API) and sorting, and then taking out score it gives NaN wheres it gives type/index.   
3. and also could anyone point me in right direction of "how to evaluate custom scores depending on the values in the file". Ok exactly what i am doing is i am hashing images into feature vectors which are stored in a file. Now to compare two feature vectors i have to calculate a distance between them, so this distance which gives similarity factor should decide the score (from what i get score is). so how to do it? i heard that we could use native scripts for that, but couldn't get it exactly.

Thanking everyone in advance.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 20, 2012, 8:27pm UTC](https://discuss.elastic.co/t/why-i-am-not-getting-any-score-in-searchrequestbuilder-after-sorting/7043/2 "2012-03-20T20:27:59Z")

</div>

On Sun, Mar 18, 2012 at 5:15 PM, rohitkondekar [rohitkondekar@gmail.com](mailto:rohitkondekar@gmail.com)wrote:

> Hello everyone,
> 
> I just got my hands on elasticsearch yesterday, because we had a  
> requirement  
> of evaluating complex mathematical queries for comparison like "evaluating  
> eculadian distances" rather than simple text matching.  
> I read that in elasticsearch, we can execute scripts as well as native  
> (java) scripts for evaluating custom scores.
> 
> So my first question was 1. what is the score exactly? and how is it  
> evaluated?

Here is a quick page that explains it:  
[http://lucene.apache.org/core/old\_versioned\_docs/versions/3\_0\_0/scoring.html](http://lucene.apache.org/core/old_versioned_docs/versions/3_0_0/scoring.html)  
.

> 1. when i am using SearchRequestBuilder (in JAVA API) and sorting, and then  
> taking out score it gives NaN wheres it gives type/index.

Yes, when doing sorting, then by default score will not be returned. You  
can call SearchRequestBuilder#setTrackScores(true) to also get scores back  
when sorting.

> 1. and also could anyone point me in right direction of "how to evaluate  
> custom scores depending on the values in the file". Ok exactly what i am  
> doing is i am hashing images into feature vectors which are stored in a  
> file. Now to compare two feature vectors i have to calculate a distance  
> between them, so this distance which gives similarity factor should decide  
> the score (from what i get score is). so how to do it? i heard that we  
> could  
> use native scripts for that, but couldn't get it exactly.

I am not too familiar with it. You could potentially index it in  
elasticsearch / Lucene, and use the raw values using a script (getting the  
values for each one). I saw a project once that indexed images into Lucene,  
using Lucene features to index the data, maybe google for it?

> Thanking everyone in advance.
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Why-i-am-not-getting-any-score-in-SearchRequestBuilder-after-sorting-tp3836699p3836699.html](http://elasticsearch-users.115913.n3.nabble.com/Why-i-am-not-getting-any-score-in-SearchRequestBuilder-after-sorting-tp3836699p3836699.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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 6, 2017, 3:35am UTC](https://discuss.elastic.co/t/why-i-am-not-getting-any-score-in-searchrequestbuilder-after-sorting/7043/3 "2017-07-06T03:35:24Z")

</div>


