Update by Query insert new child document

Hi,

i would like to know whether its possible to insert a new child document during a Update by Query task.

Our situation (simplified):
A product has n attributes modeled using a join field.

Index template:

{
    "mappings": {
        "properties": {
            "joinType": {
                "type": "join",
                "relations": {
                    "product": "attribute"
                }
            },
            "attributeId": {
                "type": "keyword"
            },
            "attributeValue": {
                "type": "keyword"
            },
            "productName": {
	        "type": "text"
            },
            "productId": {
	        "type": "keyword"
            }
        }
    }
}

And some example data:

PUT products/_doc/1
{
  "productId": 1,
  "name": "My super product",
  "joinType": "product"
}

PUT products/_doc/100?routing=1
{
  "attributeId": 100,
  "attributeName": "Price",
  "attributeValue": "20",
  "validFrom": "2022-05-01",
  "validFrom": "2022-05-31",
  "joinType": {
        "name": "attribute",
        "parent": "1"
    }
}

PUT products/_doc/200?routing=1
{
  "attributeId": 200,
  "attributeName": "Price",
  "attributeValue": "25",
  "validFrom": "2022-06-01",
  "validFrom": "2022-06-30",
  "joinType": {
        "name": "attribute",
        "parent": "1"
    }
}

The use case for this modelling is to be able to sort products based on attribute values and return them multiple times. So the query is to sort all attributes and return their parent product in the response.

The problem comes when i need to add new attributes to these products based on a query. There are a couple million products in the index. We would like to avoid running the query first and then making separate inserts for each product in the results.

Are there any recommendations on how we could achieve this or are we stuck with our approach for now?

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