2

I'm using bitwise stored information.

To deal with it in elasticsearchs Script Filter I have to use MVEL.

The MVEL Docs says to calculate bitwise the operators are the quite usual ones, so:

& -> Bitwise AND

| -> Bitwise OR

^ -> Bitwise XOR

If I try to calculate bitwise in elasticsearch using this operators elasticsearch fails with a

SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures

The filter looks like this:

"query": {
  "filtered": {
     "query": {
        "match_all": {}
     },
     "filter": {
        "script": {
           "script": "doc['options'].value == doc['options'].value | 2"
        }
     }
  }}

The field 'options' is mapped as integer. A usual operation like plus instead of the pipe would run correct and calculate correct.

Where is my bug?

maddin2code
  • 1,334
  • 1
  • 14
  • 16
  • While you may very well have good reasons to this, it sounds a lot like premature optimization. What kind of options are you storing? How many different kinds? If you can expand this to a list of options, you will most likely be better off. Lucene is really efficient at this, and the way you are trying doing it now, you will have to load the options of every single document into memory and iterate through them all, every time. – Alex Brasetvik Jan 04 '14 at 21:18
  • I already started to do the translation from the bitwise stored information to a list, because - as you said - even with script filter caching it can be kind of overhead in production. But still, if someone can tell how to solve the issue it would be very interesting to know. – maddin2code Jan 04 '14 at 21:38

0 Answers0