Unable to update multiple Elasticsearch fields

111 Views Asked by At

I have an elasticsearch index where one of the fields responsible for vectore search (KNN) has mapping like this:

"text_embeddings.predicted_value": {
              "type": "dense_vector",
              "dims": 384,
              "index": true,
              "similarity": "cosine"
            }

Other than this, there is a completely different field called "zipData" that has mapping as mentioned below:

"zipData": {
                "type": "nested",
                "properties": {
                    "zipDistribution": {
                        "type": "nested",
                        "properties": {
                            "zip": {
                                "type": "keyword"
                            },
                            "priceData": {
                                "type": "object"
                            },
                            "offerDetails": {
                                "type": "object"
                            },
                            "flags": {
                                "properties": {
                                    "itemStatus": {
                                        "type": "keyword"
                                    },
                                    "itemMessage": {
                                        "type": "keyword"
                                    },
                                    "itemMessageColor": {
                                        "type": "keyword"
                                    },
                                    "popularityScore": {
                                        "type": "integer"
                                    },
                                    "popluarityMessage": {
                                        "type": "keyword"
                                    }
                                }
                            }
                        }
                    }
                }
            }

I have used the below query to update these fields. For a non vector index it has always run fine, but I have been coming across this issue only for this particulae index with the vectors in it.

{
    "script": {
        "source": "for (int i = 0; i < ctx._source.zipData.zipDistribution.size(); i++) { if (ctx._source.zipData.zipDistribution[i].zip == params.zip) { ctx._source.zipData.zipDistribution[i].flags.itemStatus = params.itemStatus; } }",
        "lang": "painless",
        "params": {
            "zip": "55311",
            "itemStatus": "",
            "itemMessage": null,
            "itemMessageColor": null
        }
    }
}

Now, when I try to update the above fields by means of that one query, it does not let me do it, and throws the below error:

{
    "error": {
        "root_cause": [
            {
                "type": "document_parsing_exception",
                "reason": "[1:10365] failed to parse: Field [text_embedding.predicted_value] of type [dense_vector] doesn't not support indexing multiple values for the same field in the same document"
            }
        ],
        "type": "document_parsing_exception",
        "reason": "[1:10365] failed to parse: Field [text_embedding.predicted_value] of type [dense_vector] doesn't not support indexing multiple values for the same field in the same document",
        "caused_by": {
            "type": "illegal_argument_exception",
            "reason": "Field [text_embedding.predicted_value] of type [dense_vector] doesn't not support indexing multiple values for the same field in the same document"
        }
    },
    "status": 400
}
0

There are 0 best solutions below