You shouldn't be using the JSON input for scripts. The best way to do it is by using the scripted fields option already available in Kibana. You get a detailed guide in that page and a way to test everything based on your data.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.