# Precision in groovy scripts

**URL:** <https://discuss.elastic.co/t/precision-in-groovy-scripts/21187>\
**Category:** Elasticsearch\
**Created:** [December 10, 2014, 1:43pm UTC](https://discuss.elastic.co/t/precision-in-groovy-scripts/21187 "2014-12-10T13:43:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pedro\_Cunha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pedro_cunha/32/1056_2.png) [@Pedro\_Cunha](https://discuss.elastic.co/u/Pedro_Cunha)\
**Post date:** [December 10, 2014, 1:43pm UTC](https://discuss.elastic.co/t/precision-in-groovy-scripts/21187/1 "2014-12-10T13:43:33Z")

</div>

Hello,

I'm having an issue handling big integers in script params. Can someone  
please explain to me this behaviour:

Scenario a:  
GET a/\_search  
{  
"track\_scores": true,  
"fields": "\_score",  
"size": 1,  
"query": {  
"filtered": {  
"query": {  
"function\_score": {  
"score\_mode": "sum",  
"script\_score": {  
"script": "return a;",  
"params": {  
"a": 1414018800000,  
"b": 1414627200000  
}  
}  
}  
}  
}  
}  
}

Returns  
{  
"took": 1,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 10,  
"max\_score": 1414018760000,  
"hits": [  
{  
"\_index": "test",  
"\_type": "a",  
"\_id": "73",  
"\_score": 1414018760000  
}  
]  
}  
}

Returning "a" from the script score, the \_score value is different from a: 1414018800000  
!= 1414018760000

Scenario b:  
GET a/\_search  
{  
"track\_scores": true,  
"fields": "\_score",  
"size": 1,  
"query": {  
"filtered": {  
"query": {  
"function\_score": {  
"score\_mode": "sum",  
"script\_score": {  
"script": "return b;",  
"params": {  
"a": 1414018800000,  
"b": 1414627200000  
}  
}  
}  
}  
}  
}  
}

Returns  
{  
"took": 1,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 10,  
"max\_score": 1414627200000,  
"hits": [  
{  
"\_index": "search\_test",  
"\_type": "property",  
"\_id": "73",  
"\_score": 1414627200000  
}  
]  
}  
}

Returning "b" from the script score, the \_score value is equal to b 1414627200000  
== 1414627200000

Is ES not able to tell the precision required for that number ?

Thanks,  
Pedro

--  
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/08ed79fa-93ec-4934-ac83-b04e3971d188%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/08ed79fa-93ec-4934-ac83-b04e3971d188%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, 12:44am UTC](https://discuss.elastic.co/t/precision-in-groovy-scripts/21187/2 "2017-07-06T00:44:28Z")

</div>


