# Native(Java) script performance

**URL:** <https://discuss.elastic.co/t/native-java-script-performance/19268>\
**Category:** Elasticsearch\
**Created:** [August 13, 2014, 7:36pm UTC](https://discuss.elastic.co/t/native-java-script-performance/19268 "2014-08-13T19:36:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![avacados\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/avacados_2/32/1335_2.png) [@avacados\_2](https://discuss.elastic.co/u/avacados_2)\
**Post date:** [August 13, 2014, 7:36pm UTC](https://discuss.elastic.co/t/native-java-script-performance/19268/1 "2014-08-13T19:36:02Z")

</div>

is there any documents available about performance of native script ?? I am  
facing search performance issue due to native script. General guideline to  
optimize script performance will be helpful.

Here is specific details where i am facing performance issue.

I am using script to find documents which overlap betweens two date ranges.  
(i.e. find documents between [01-Aug, 2-Nov]... where document contain two  
fields (start\_time, end\_time)) . First, startRange-endRange are params.

My script filter is,

===================  
{  
"script": {  
"script": "xyz",  
"params": {  
"startRange": 1407939675, // Timestamp in  
milliseconds  
"endRange": 1410531675 // Timestamp in  
milliseconds  
},  
"lang": "native",  
"\_cache": true  
}  
},

===================  
My Native(Java) script code

====================

ScriptDocValues XsDocValue = (ScriptDocValues) doc().get(

"start\_time");

long XsLong = 0l;

if (XsDocValue != null && !XsDocValue.isEmpty()) {

XsLong = ((ScriptDocValues.Longs) doc().get("start\_time"))

.getValue();

}

ScriptDocValues XeDocValue = (ScriptDocValues) doc().get("end\_time");

long XeLong = 0l;

if (XeDocValue != null && !XeDocValue.isEmpty()) {

XeLong = ((ScriptDocValues.Longs) doc().get("end\_time"))

.getValue();

}

if ((endRange \>= XsLong) && (startRange \<= XeLong)) {

return true;

}

===========================

--  
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/e6f056a0-4e47-4e04-abd2-e74f27bd2e68%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e6f056a0-4e47-4e04-abd2-e74f27bd2e68%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:08am UTC](https://discuss.elastic.co/t/native-java-script-performance/19268/2 "2017-07-06T01:08:49Z")

</div>


