# Custom score based on highlighted content

**URL:** <https://discuss.elastic.co/t/custom-score-based-on-highlighted-content/7527>\
**Category:** Elasticsearch\
**Created:** [May 2, 2012, 3:01am UTC](https://discuss.elastic.co/t/custom-score-based-on-highlighted-content/7527 "2012-05-02T03:01:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Klerisson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klerisson/32/2878_2.png) [@Klerisson](https://discuss.elastic.co/u/Klerisson)\
**Post date:** [May 2, 2012, 3:01am UTC](https://discuss.elastic.co/t/custom-score-based-on-highlighted-content/7527/1 "2012-05-02T03:01:58Z")

</div>

Greetings!  
Are there any way to build a custom score based on highlighted  
content?

I mean, given a query against a set of documents the score of each hit  
should be given by the number of highlighting content found on each  
document. I just need to find a way to sort my hits based on the  
relevance, in my case the number of highlighted content.

Thanks 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:** [May 2, 2012, 4:32pm UTC](https://discuss.elastic.co/t/custom-score-based-on-highlighted-content/7527/2 "2012-05-02T16:32:47Z")

</div>

Scoring in Lucene already works (very simplified) like that...

On Wed, May 2, 2012 at 6:01 AM, Klérisson Paixão  
[klerissonpaixao@gmail.com](mailto:klerissonpaixao@gmail.com)wrote:

> Greetings!  
> Are there any way to build a custom score based on highlighted  
> content?
> 
> I mean, given a query against a set of documents the score of each hit  
> should be given by the number of highlighting content found on each  
> document. I just need to find a way to sort my hits based on the  
> relevance, in my case the number of highlighted content.
> 
> Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Klerisson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klerisson/32/2878_2.png) [@Klerisson](https://discuss.elastic.co/u/Klerisson)\
**Post date:** [May 17, 2012, 1:54am UTC](https://discuss.elastic.co/t/custom-score-based-on-highlighted-content/7527/3 "2012-05-17T01:54:19Z")

</div>

How to enable such scoring to "query\_string" against "\_all" field? I'm getting 1.0 score for all hits, no clue why.

Thanks!

--- Edit  
Getting 1.0 score for all hits has something to do with wildcards query? Or even worst: a leading wildcard?

---

<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:** [May 22, 2012, 11:21am UTC](https://discuss.elastic.co/t/custom-score-based-on-highlighted-content/7527/4 "2012-05-22T11:21:05Z")

</div>

What query are you executing? If its wildcard query, then it transforms  
into a constant score one (has nothing to do with \_all field).

On Thu, May 17, 2012 at 3:54 AM, Klerisson [klerissonpaixao@gmail.com](mailto:klerissonpaixao@gmail.com)wrote:

> How to enable such scoring to "query\_string" against "\_all" field? I'm  
> getting 1.0 score for all hits, no clue why.
> 
> Thanks!
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Custom-score-based-on-highlighted-content-tp3954342p3998333.html](http://elasticsearch-users.115913.n3.nabble.com/Custom-score-based-on-highlighted-content-tp3954342p3998333.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:27am UTC](https://discuss.elastic.co/t/custom-score-based-on-highlighted-content/7527/5 "2017-07-06T03:27:40Z")

</div>


