I want to create a (url,visits)
index on elasticsearch
which will hold the number of visits a particular url every time I call function myfunction
. How can I do that? So far, I have managed to create the insertion but I am unable to increase the counter.
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)