# 'out of float scope for function score deviation' error using function\_score and a gauss decay

**URL:** <https://discuss.elastic.co/t/out-of-float-scope-for-function-score-deviation-error-using-function-score-and-a-gauss-decay/20092>\
**Category:** Elasticsearch\
**Created:** [October 6, 2014, 4:20pm UTC](https://discuss.elastic.co/t/out-of-float-scope-for-function-score-deviation-error-using-function-score-and-a-gauss-decay/20092 "2014-10-06T16:20:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jilles\_van\_Gurp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jilles_van_gurp/32/879_2.png) [@Jilles\_van\_Gurp](https://discuss.elastic.co/u/Jilles_van_Gurp)\
**Post date:** [October 6, 2014, 4:20pm UTC](https://discuss.elastic.co/t/out-of-float-scope-for-function-score-deviation-error-using-function-score-and-a-gauss-decay/20092/1 "2014-10-06T16:20:26Z")

</div>

Using elasticsearch 1.3.4

I have an index with user events and I'm trying to use function\_score to  
get a sensible order by date (without using sort). The query below works,  
but only for relatively small result sets. While trying to test whether  
this orders things correctly (following up on a report that they were not),  
I ran into this error while trying the query with 10K events spread over  
1000 days. With just a 100 days it works fine. But with 10000 events and  
some a few years back the gauss of 10d seems to trigger some corner case in  
elasticsearch that produces an error.

Query Failed [Failed to execute main query]]; nested: AssertionError[input  
4.3876046562428303E-75 out of float scope for function score deviation:  
1.0]; }

I've since changed the query slightly to using exp decay function with 365d  
and that seems to work better for my usecase. However, I'm wondering  
whether gauss throwing an error like this should be considered a bug? Why  
not simply round to 0 if the difference becomes to small to be meaningful?

Here's the original query. Note, it is programmatically generated and can  
be a lot more complex, which is why I like using a function\_score here  
instead of a sort. But if you are wondering about the nested term filter,  
that's the reason.  
{  
"from":0,  
"size":100000,  
"version":true,  
"query":{  
"filtered":{  
"query":{  
"function\_score":{  
"query":{  
"match\_all":{  
}},  
"score\_mode":"max",

"functions":[  
{  
"gauss":{  
"event\_at":{  
"origin":"2014-10-06T15:51:35Z",  
"scale":"10d"  
}}}]}},  
"filter":{  
"and":[  
{  
"or":[  
{  
"term":{  
"user\_id":"GqIxYkaEz\_L0\_7Ge299X6Q"  
}}]}]}}}}

--  
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/531330c4-3fda-4c16-8780-243bcfab76d8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/531330c4-3fda-4c16-8780-243bcfab76d8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![sschwell](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@sschwell](https://discuss.elastic.co/u/sschwell)\
**Post date:** [September 20, 2016, 1:58pm UTC](https://discuss.elastic.co/t/out-of-float-scope-for-function-score-deviation-error-using-function-score-and-a-gauss-decay/20092/2 "2016-09-20T13:58:06Z")

</div>

+1  
this looks like a bug

---

<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 5, 2017, 10:18pm UTC](https://discuss.elastic.co/t/out-of-float-scope-for-function-score-deviation-error-using-function-score-and-a-gauss-decay/20092/3 "2017-07-05T22:18:47Z")

</div>


