Bulk update through MVEL Script


(Rajesh) #1

Hi, I am using elasticsearch 1.3.7

{
.
.
.
custId : "String",
custName :"String",
terrid : "Long",
terrname: "String"
.
.
.
}
In the beginning I have a mapping as above and I indexed (save) some document.
But right now I want to put the Terrid and Tername in nested as below.

{
.
.
.
custId : "String",
custName :"String",
terrs: {
type" : "nested",
"properties" : {
"id" : {
"type" : "string",
},
"terrId" : {
"type" : "long",
},
"terrName" : {
"type" : "string",
}
}
}
.
.
.
}

And I did.

My query is how to update the existing document which do not have a field called "terrs"
(without re-index/migration), through MVEL Script.

The following code is what we did.
updateScript.append("ctx._source['terrs'] = '" + toJson(terrList) + "';");

We get the following exception

ElasticSearchEJBBean : bulkUpdate : Failure reason :: failure in bulk execution:
[0]: index [db2], type [3], id [263270], message [MapperParsingException[object mapping for [3] tried to parse as object, but got EOF, has a concrete value been provided to it?]]


(Nik Everett) #2

Please use the ``` to quote code so discuss preserves spaces.

I don't know that error off hand but this isn't how I'd do the update anyway. It ought to be something as simple as a couple of ifs that check for the value being present.

For what it is worth MVEL and 1.3.7 are very deprecated. MVEL has all kinds of issues and 1.3.7 is old enough few folks are likely to remember it well.


(Rajesh) #3

Hi, I tried with '[quote="nik9000, post:2, topic:60766"]

[/quote]

but not working any other way to resolve.

(system) #4