# Customising scoring algorithm in elasticsearch with scoring script or building my own Lucene Scorer?

**URL:** <https://discuss.elastic.co/t/customising-scoring-algorithm-in-elasticsearch-with-scoring-script-or-building-my-own-lucene-scorer/13577>\
**Category:** Elasticsearch\
**Created:** [September 12, 2013, 7:52pm UTC](https://discuss.elastic.co/t/customising-scoring-algorithm-in-elasticsearch-with-scoring-script-or-building-my-own-lucene-scorer/13577 "2013-09-12T19:52:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![11122](https://avatars.discourse-cdn.com/v4/letter/1/6a8cbe/32.png) [@11122](https://discuss.elastic.co/u/11122)\
**Post date:** [September 12, 2013, 7:52pm UTC](https://discuss.elastic.co/t/customising-scoring-algorithm-in-elasticsearch-with-scoring-script-or-building-my-own-lucene-scorer/13577/1 "2013-09-12T19:52:59Z")

</div>

I'm using elasticsearch to do some similarity comparison among process  
models. The core similarity algorithm should be specialized for my process  
models, which means, as my imagined, I should customize the score algorithm  
in elasticsearch.

As I known, the scoring in ES is based on Lucene score algorithm. Although  
Lucene's DefaultSimilarity works quite well on most of the cases and one  
can use other similarities in ES like BM25,DRF, such customizing usually  
extending the existed Lucene classes or overriding its methods to change or  
disable some weights in my opinion.

In my case, I'd like to make some specialized math things which should be  
used as scoring and seems to be different with the base Lucene score  
algorithm. what confused me is, it seems that there are two options for me,  
one is, I can configurate custom scoring script in ES, the other one is I  
should build my own Lucene scorer.

Can anybody give me some advice on which approach I should take? or is  
there any missunderstanding I have. Since I have not very clear about ES  
and Lucene, maybe there are some other ways to solve my questions and more  
suitable in my case. Thanks a lot!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [September 13, 2013, 9:35am UTC](https://discuss.elastic.co/t/customising-scoring-algorithm-in-elasticsearch-with-scoring-script-or-building-my-own-lucene-scorer/13577/2 "2013-09-13T09:35:10Z")

</div>

It kinda depends how complex your scoring algorithm needs to be. If it is  
just an algorithm based on the values contained in fields in each doc, then  
a custom\_score script may be what you want. If it is more complex, then you  
may need to implement your own similarity module.

clint

On 12 September 2013 21:52, 少爷允之 [chang.zhang29@googlemail.com](mailto:chang.zhang29@googlemail.com) wrote:

> I'm using elasticsearch to do some similarity comparison among process  
> models. The core similarity algorithm should be specialized for my process  
> models, which means, as my imagined, I should customize the score algorithm  
> in elasticsearch.
> 
> As I known, the scoring in ES is based on Lucene score algorithm. Although  
> Lucene's DefaultSimilarity works quite well on most of the cases and one  
> can use other similarities in ES like BM25,DRF, such customizing usually  
> extending the existed Lucene classes or overriding its methods to change or  
> disable some weights in my opinion.
> 
> In my case, I'd like to make some specialized math things which should be  
> used as scoring and seems to be different with the base Lucene score  
> algorithm. what confused me is, it seems that there are two options for me,  
> one is, I can configurate custom scoring script in ES, the other one is I  
> should build my own Lucene scorer.
> 
> Can anybody give me some advice on which approach I should take? or is  
> there any missunderstanding I have. Since I have not very clear about ES  
> and Lucene, maybe there are some other ways to solve my questions and more  
> suitable in my case. Thanks a lot!
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![11122](https://avatars.discourse-cdn.com/v4/letter/1/6a8cbe/32.png) [@11122](https://discuss.elastic.co/u/11122)\
**Post date:** [September 15, 2013, 11:39am UTC](https://discuss.elastic.co/t/customising-scoring-algorithm-in-elasticsearch-with-scoring-script-or-building-my-own-lucene-scorer/13577/3 "2013-09-15T11:39:40Z")

</div>

Thanks for your advice.  
As I imagined, the scoring algorithm should based on the values of fields  
and further work on these values, maybe more complex. You said, maybe I  
need to implement my own similarity module, is that mean, I should write my  
scripts which are responsible for scoring and then build in ES as a plugin  
like this example showed:  
[GitHub - imotov/elasticsearch-native-script-example: Example of Now Deprecated Native Script Plugin for Elasticsearch](https://github.com/imotov/elasticsearch-native-script-example). So it is  
possible that I don't need to do something in Lucene? I think that will be  
easier for me. Thanks!

在 2013年9月13日星期五UTC+2上午11时35分10秒，Clinton Gormley写道：

> It kinda depends how complex your scoring algorithm needs to be. If it is  
> just an algorithm based on the values contained in fields in each doc, then  
> a custom\_score script may be what you want. If it is more complex, then you  
> may need to implement your own similarity module.
> 
> clint
> 
> On 12 September 2013 21:52, 少爷允之 \<[chang....@googlemail.com](mailto:chang....@googlemail.com) \<javascript:\>\>wrote:
> 
> > I'm using elasticsearch to do some similarity comparison among process  
> > models. The core similarity algorithm should be specialized for my process  
> > models, which means, as my imagined, I should customize the score algorithm  
> > in elasticsearch.
> > 
> > As I known, the scoring in ES is based on Lucene score algorithm.  
> > Although Lucene's DefaultSimilarity works quite well on most of the cases  
> > and one can use other similarities in ES like BM25,DRF, such customizing  
> > usually extending the existed Lucene classes or overriding its methods to  
> > change or disable some weights in my opinion.
> > 
> > In my case, I'd like to make some specialized math things which should be  
> > used as scoring and seems to be different with the base Lucene score  
> > algorithm. what confused me is, it seems that there are two options for me,  
> > one is, I can configurate custom scoring script in ES, the other one is I  
> > should build my own Lucene scorer.
> > 
> > Can anybody give me some advice on which approach I should take? or is  
> > there any missunderstanding I have. Since I have not very clear about ES  
> > and Lucene, maybe there are some other ways to solve my questions and more  
> > suitable in my case. Thanks a lot!
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:16am UTC](https://discuss.elastic.co/t/customising-scoring-algorithm-in-elasticsearch-with-scoring-script-or-building-my-own-lucene-scorer/13577/4 "2017-07-06T02:16:29Z")

</div>


