Adding a New field to index

I want to add a new field to my index which includes more than 20m documents. I have dictionary like this Template : [Catalog_id : {Keyword: Sold Count}]

Sold Counts = {1234: {Apple:50}, 3242: {Banana:20}, 3423: {Apple:23}, ...}

In the index, there are many documents which share the same catalog_id. According to each document's catalog_id, I want to add a new field.
_id: 12323423423, catalog_id: 1234, name: '....', **Sold Count: [Apple,50]**

What is the best way to insert a new field in this situtation?

POST test/_update_by_query
{
  "query": {
    "term": {
      "catalog_id": 12345
    }
  },
  "script" : {
    "source": "ctx._source.topics = HERE WHAT TO PUT",
    "lang": "painless"
  }
}

I have found update by query function, but I need to fulfill topics field as rank_feature. How can I do it? For example : {"milk":500}

rank_feature

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