# Get max(\_score) in function score query

**URL:** https://discuss.elastic.co/t/get-max--score-in-function-score-query/16470
**Category:** Elasticsearch
**Created:** [March 19, 2014, 3:34pm UTC](https://discuss.elastic.co/t/get-max--score-in-function-score-query/16470 "2014-03-19T15:34:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ian\_Neubert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_neubert/32/1686_2.png) [@Ian\_Neubert](https://discuss.elastic.co/u/Ian_Neubert)
#### Post date: [March 19, 2014, 3:34pm UTC](https://discuss.elastic.co/t/get-max--score-in-function-score-query/16470/1 "2014-03-19T15:34:19Z")

</div>

Is it possible to get the maximum \_score from all search results inside the  
function of a function score query?

For example: [https://gist.github.com/ianneub/6a165d3206ad83dfdbdf](https://gist.github.com/ianneub/6a165d3206ad83dfdbdf)

This is a simplistic example, but what I might do with the data is include  
or not include certain computation in my\_computed\_score depending on the  
max \_score.

Thanks!

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/11628aa1-48d5-4534-b8dc-74080a9768a5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/11628aa1-48d5-4534-b8dc-74080a9768a5%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [March 31, 2014, 7:02am UTC](https://discuss.elastic.co/t/get-max--score-in-function-score-query/16470/2 "2014-03-31T07:02:38Z")

</div>

Hey,

will the max score\_mode help you here or did I misunderstand your question?  
See

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Or do you want to reuse that maximum score inside of a computation of the  
function score? That wont work iirc...

--Alex

On Wed, Mar 19, 2014 at 4:34 PM, Ian Neubert [ian@ianneubert.com](mailto:ian@ianneubert.com) wrote:

> Is it possible to get the maximum \_score from all search results inside  
> the function of a function score query?
> 
> For example: [query.json · GitHub](https://gist.github.com/ianneub/6a165d3206ad83dfdbdf)
> 
> This is a simplistic example, but what I might do with the data is include  
> or not include certain computation in my\_computed\_score depending on the  
> max \_score.
> 
> Thanks!
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/11628aa1-48d5-4534-b8dc-74080a9768a5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/11628aa1-48d5-4534-b8dc-74080a9768a5%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/11628aa1-48d5-4534-b8dc-74080a9768a5%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/11628aa1-48d5-4534-b8dc-74080a9768a5%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM-n39i4O0QOHP7rXnoZWd05Cy%2BqxZH80TSc4a-%2BzS2OzA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM-n39i4O0QOHP7rXnoZWd05Cy%2BqxZH80TSc4a-%2BzS2OzA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Ian\_Neubert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_neubert/32/1686_2.png) [@Ian\_Neubert](https://discuss.elastic.co/u/Ian_Neubert)
#### Post date: [March 31, 2014, 2:07pm UTC](https://discuss.elastic.co/t/get-max--score-in-function-score-query/16470/3 "2014-03-31T14:07:28Z")

</div>

Thank you for your reply Alex.

I'm actually trying to use the max score inside of the computation--the  
MVEL script function--inside the function score query.

On Monday, March 31, 2014 12:02:38 AM UTC-7, Alexander Reelsen wrote:

> Hey,
> 
> will the max score\_mode help you here or did I misunderstand your  
> question? See  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#_using_function_score)
> 
> Or do you want to reuse that maximum score inside of a computation of the  
> function score? That wont work iirc...
> 
> --Alex
> 
> On Wed, Mar 19, 2014 at 4:34 PM, Ian Neubert \<[i...@ianneubert.com](mailto:i...@ianneubert.com)\<javascript:\>
> 
> > wrote:
> 
> > Is it possible to get the maximum \_score from all search results inside  
> > the function of a function score query?
> > 
> > For example: [query.json · GitHub](https://gist.github.com/ianneub/6a165d3206ad83dfdbdf)
> > 
> > This is a simplistic example, but what I might do with the data is  
> > include or not include certain computation in my\_computed\_score depending  
> > on the max \_score.
> > 
> > Thanks!
> > 
> > --  
> > 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:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/11628aa1-48d5-4534-b8dc-74080a9768a5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/11628aa1-48d5-4534-b8dc-74080a9768a5%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/11628aa1-48d5-4534-b8dc-74080a9768a5%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/11628aa1-48d5-4534-b8dc-74080a9768a5%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4b47c4db-910e-4e14-bafb-7f12cd11c032%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4b47c4db-910e-4e14-bafb-7f12cd11c032%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:39am UTC](https://discuss.elastic.co/t/get-max--score-in-function-score-query/16470/4 "2017-07-06T01:39:23Z")

</div>


