# Minimum double score in a native script

**URL:** <https://discuss.elastic.co/t/minimum-double-score-in-a-native-script/20308>\
**Category:** Elasticsearch\
**Created:** [October 17, 2014, 6:21pm UTC](https://discuss.elastic.co/t/minimum-double-score-in-a-native-script/20308 "2014-10-17T18:21:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Sierra](https://avatars.discourse-cdn.com/v4/letter/a/9f8e36/32.png) [@Alejandro\_Sierra](https://discuss.elastic.co/u/Alejandro_Sierra)\
**Post date:** [October 17, 2014, 6:21pm UTC](https://discuss.elastic.co/t/minimum-double-score-in-a-native-script/20308/1 "2014-10-17T18:21:52Z")

</div>

Hi!,

I am writing a Java plugin with a customized score script (native)  
returning a double. Basically I wrote a class extending  
AbstractDoubleSearchScript.  
For some documents which don't pass a specific test, the score should be  
the lowest possible, meaning they should be at the bottom of the results.  
Its is hard for me to find a lower bound for my scores, since they are  
logarithms of probabilities. (the theoretical lower bound is log(0))  
I have tried returning in the runAsDouble() method  
Double.NEGATIVE\_INFINITY and also  
(-Double.MAX\_VALUE)  
since the Double.MIN\_VALUE is not actualy the minimum negative value (I  
guess the name of that constant is not consistent with the one for  
Integer.MIN\_VALUE but that's a different story).

When I return the aforementioned constants I get an error:  
java.lang.IllegalArgumentException: docID must be \>= 0 and \<  
maxDoc=58514550 (got docID=2147483647)  
at  
org.apache.lucene.index.BaseCompositeReader.readerIndex(BaseCompositeReader.java:182)  
at  
org.apache.lucene.index.BaseCompositeReader.document(BaseCompositeReader.java:109)  
at org.apache.lucene.search.IndexSearcher.doc(IndexSearcher.java:196)  
at  
org.elasticsearch.search.fetch.FetchPhase.loadStoredFields(FetchPhase.java:228)  
at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:156)  
at  
org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:340)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$11.call(SearchServiceTransportAction.java:308)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$11.call(SearchServiceTransportAction.java:305)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:722)

I am using ES 1.2.0 on a single machine. and the query is formed like this:

{  
"query" : {  
"function\_score" : {  
"query" : {  
//some filters  
},  
"script\_score" : {  
"script" : "my\_script",  
"lang" : "native",  
"params" : {  
//some parameters  
}  
},  
"score\_mode" : "first",  
"boost\_mode" : "replace"  
}  
}  
}

Cheers

--  
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/67ebe35f-d58c-4890-aacb-b7647fcde75a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/67ebe35f-d58c-4890-aacb-b7647fcde75a%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:55am UTC](https://discuss.elastic.co/t/minimum-double-score-in-a-native-script/20308/2 "2017-07-06T00:55:26Z")

</div>

Closed on July 6, 2017, 12:55am UTC


