How to make elastic increase a counter on every update?
<p>I want to create a <code>(url,visits)</code> index on <code>elasticsearch</code> which will hold the number of visits a particular url every time I call function <code>myfunction</code>. How can I do that? So far, I have managed to create the insertion but I am unable to increase the counter.</p>

<pre><code>def myfunction():
    a = elasticsearch.index(index='test_index_1' , doc_type='test_doc_type' , id="url" , body={'data' : {'visits' : 1} , 'doc_as_upsert' : True})
    app.logger.info(a)
    b = elasticsearch.update(index='test_index_1' , doc_type='test_doc_type' , id="url" , body={
        'script' : 'ctx._source.data.visits += visit',
        'params' : {
            'visit' : 1
        }
    })
    app.logger.info(b)
</code></pre>