0

I try to add new field which is value comes from hashed existing field value. So, i want to do; my_index.hashedusername(new field) = crc32(my_index.username) (existing field)

For example

POST  _update_by_query
{
  "query": {
    "match_all": {}
  },
  "script" : {
      "source": "ctx._source.hashedusername = crc32(ctx._source.username);"
  }
}

Please give me an idea how to do this..

data_m
  • 124
  • 1
  • 9

1 Answers1

1

java.util.zip.CRC32 is not available in the shared painless API so mocking that package will be non-trivial -- perhaps even unreasonable.

I'd suggest to compute the CRC32 hashes beforehand and only then send the docs to ES. Alternatively, scroll through all your documents, compute the hash and bulk-update your documents.

The painless API was designed to perform comparatively simple tasks and CRC32 is certainly outside of its purpose.

Joe - GMapsBook.com
  • 15,787
  • 4
  • 23
  • 68