Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a 'users' elasticsearch index, where a user looks like:

{
  "id" : 1,
  "name" : "Jeroen",
  "hours": [8,9,10,11,12,19,20,21,22,23],
  "country": "NL",
  "utc_offset": 1.0
}

I want to find all users of which the 'hours' field contains the current hour in their local time. So for example, I only want to find the above user when it's between 8.00-12.00 or 20.00-23.00 in the Netherlands.

My solution for this is using a script filter. I didn't know how to implement this with MVEL, so I installed the javascript plugin. Now my query looks like this:

{
  "query": {
    "match_all": {}
  },"filter": {
    "script": {
       "script": "var a = doc['hours'].values; var d = new Date(); d.setTime(d.getTime() + doc['utc_offset'].value * 3600 * 1000); a.indexOf('' + d.getHours()) != -1",
       "params": {}
    }
  }
}

So this works, but after a while elasticsearch is starting to throw exceptions, like this:

{
  "error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[x9FlNmmsT26hJbrfnyH2uA][users][2]: QueryPhaseExecutionException[[users][2]: query[ConstantScore(*:*)],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: IllegalAccessError[org/elasticsearch/index/fielddata/ScriptDocValues$Strings$1]; }{[x9FlNmmsT26hJbrfnyH2uA][users][3]: QueryPhaseExecutionException[[users][3]: query[ConstantScore(*:*)],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: IllegalAccessError[org/elasticsearch/index/fielddata/ScriptDocValues$Strings$1]; }{[x9FlNmmsT26hJbrfnyH2uA][users][0]: QueryPhaseExecutionException[[users][0]: query[ConstantScore(*:*)],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: IllegalAccessError[org/elasticsearch/index/fielddata/ScriptDocValues$Strings$1]; }{[x9FlNmmsT26hJbrfnyH2uA][users][2]: QueryPhaseExecutionException[[users][3]: query[ConstantScore(*:*)],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: IllegalAccessError[org/elasticsearch/index/fielddata/ScriptDocValues$Strings$1]; }{[x9FlNmmsT26hJbrfnyH2uA][users][4]: QueryPhaseExecutionException[[users][4]: query[ConstantScore(*:*)],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: IllegalAccessError[org/elasticsearch/index/fielddata/ScriptDocValues$Strings$1]; }]",
"status": 500

}

A similar issue was posted where it was suggested it's a problem with the JIT compiler. As a workaround it was suggested to disable it by using '-Dmvel2.disable.jit=true'. I've tried this, by putting it in ES_JAVA_OPTS in /etc/default/elasticsearch but it didn't seem to have any effect.

Does anybody have a clue what's going wrong and how to fix it, or have an alternative way of performing this query?

share|improve this question
    
You might want to open up another issue, or add yours to the one that you referenced. –  pickypg Mar 28 at 2:06
    
@pickypg I thought of that, but if it's really a JIT issue, they're probably gonna close it again –  Jeroen Rosenberg Mar 28 at 8:22
    
@JeroenRosenberg I guess we close it when we find a solution for it? Not sure though how you can solve this issue the same way if you're using the lang-javascript plugin. –  javanna Mar 28 at 10:17
    
@javanna I opened one here github.com/elasticsearch/elasticsearch/issues/5590 In there I reference the related issue that was closed without a solution –  Jeroen Rosenberg Mar 28 at 11:09
    
Thanks for opening the issue! –  javanna Mar 28 at 11:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.