Created
October 9, 2018 11:58
-
-
Save hbresic/30ae58be8a1f68a052ba62cabd08e94b to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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);" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment