The best way to append to an Array in Elasticsearch utilizing elasticsearch-py

If you’re utilizing the Official ElasticSearch Python library (Docs), and also you need to create an index:

doc = {
    "one thing": "123a",
    "somethingelse": "456b",
    "historical past": []
es.index(index="someindex", doc_type="somedoctype", id="someid", physique=doc)

You possibly can append objects to the historical past every time, as an alternative of overriding them, like this:

es.replace(index="someindex", doc_type="somedoctype", id="someid",
        "script" : {
            "supply": "ctx._source.historical past.addAll(params.historical past)",
            "lang": "painless",
            "params" : {
                "historical past" : ["item1","item2"]

This makes use of scripted updates in Elasticsearch, for appending to an array.