XOR on vector parameters

Hi,

I want to do an xor on vectors in a painless scoring script.
ATM I'm iterating over one vector and xoring each entry with the corresponding entry in the query vector.
Is there a way I can do it in a single command?

For example, I'm doing this now:

"script_score": {
        "script": {
          "lang": "painless",
          "source": "def c = 0; def dist = params._source['vector']) { dist += (dim^params.vector[c]); c++; if (dist > 32) { break; } } return 256 - dist;",
          "params": {
              "vector": [0, 1, 0, 1, 0, 0,..., 1, 0, 0, 1, 0, 0, 1, 0]
          }
        }
      }

Is something like this possible instead:

"script_score": {
        "script": {
          "lang": "painless",
          "source": "return 256 - params._source['vector']^params.vector;",
          "params": {
              "vector": [0, 1, 0, 1, 0, 0,..., 1, 0, 0, 1, 0, 0, 1, 0]
          }
        }
      }

Would this be possible if I represented the vector (which is binary) as a binary data type?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.