Python: bulk updating with a new field, contents of that field are inside a json


(Mariska Willemsen) #1

I have some data in elasticsearch and I want to bulkupdate each document with a new field. I have a json that looks like this(lists can also contain multiple dicts):

{
"uniquecode1": [{
"stuff": "things"
}],
"uniquecode2": [{
"things": "stuff"
}]
}

The data already in elastic looks a bit like this:

{
"code": "abc",
"things": "stuff",
"more": "less"
}

What I want it to look like is this:

{
"code": "abc",
"things": "stuff",
"more": "less"
"newstuff": [{
"stuff": "things"
}]
}

The Uniquecode keys in the json are the codes that identify the documents in elastic, the ID. Is there a way I can say, the key of this json is the ID number, and the body is an update with new field "newstuff" which contains the values of this json.I don't know how to couple the key in the json with the docID and tell it to use the value of this key (list of dicts), as body for the new field. Hopefully someone has some insight!


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.