Skip to content

Instantly share code, notes, and snippets.

@hbresic
hbresic / remove-junk-fields.es
Created October 9, 2018 11:58
Stored Painless script for removing junk header field in Elasticsearch reindexing process. Targets 10 and 16 length string without dash (e.g. HTTP_CPKHHLZ9WM) and excludes HTTP_CONNECTION as that is only header required of this construction.
{
"script": {
"lang": "painless",
"source": "String match = null; for (f in ctx._source.entrySet()) { def m = /^HTTP_([^_]{16}|[^_]{10})$/.matcher(f.getKey()); if (m.find() && f.getKey() != 'HTTP_CONNECTION') { match = f.getKey(); break;}} ctx._source.remove(match);"
}
}

Keybase proof

I hereby claim:

  • I am hbresic on github.
  • I am hbresic (https://keybase.io/hbresic) on keybase.
  • I have a public key ASA-GOj69s_Ff9M-IhZSLTrfDaie4g9BlV-7NUP79MTYOgo

To claim this, I am signing this object: