How to enforce valid json in elastic search?
<p>Consider following code: </p>

<pre><code>function add_document() {
    index=$1
    _type=$2
    json="$3"

    curl -s -X PUT "$NODE_ADDRESS/index/_type?pretty" -d "$json"
}

add_document users documents '{user_name : "kshitiz"}'
</code></pre>

<p>The above function runs just fine and adds the document to the index. The problem however is that <code>{user_name : "kshitiz"}</code> isn't valid JSON.</p>

<p>I can validate the JSON in my code before sending to Elastic but the problem is that this instance would be shared among a large team. A better solution would be to disable invalid JSON as acceptable documents at the node so that add operation would fail and force developers to code properly.</p>

<p>How can I enable strict JSON validation in Elastic?</p>