I'm trying to update a object in elasticsearch, but I'm having the next error message:
Elasticsearch exception [type=mapper_parsing_exception, reason=object mapping for [errorMessages] tried to parse field [errorMessages] as object, but found a concrete value]
This is my mappings:
{
.hierarchies: {
mappings: {
hierarchy: {
dynamic: "strict",
_all: {
enabled: false
},
properties: {
errorFlag: {
type: "keyword"
},
errorMessages: {
properties: {
isFavourite: {
type: "text"
},
message: {
type: "text"
}
}
},
}
}
}
And the information that I'm trying to update is this:
"errorMessages" -> "{"isFavourite":"yes","message":"hola"}"
I use the rest client connector and the object UpdateRequest:
UpdateRequest updateRequest = new UpdateRequest(
collection,
type,
id);
updateRequest.doc(document);
updateRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
try {
return esConnector.getRestClient().update(
updateRequest, RequestOptions.DEFAULT);
} catch (IOException e) {
throw new ElasticsearchGenericException("Error updating document " + collection + " > " + type + " id: " + id + " (Reason: " + e.getMessage() + ")");
}
}
The value of the document is the json with the errorMessages. And this is the UpdateRequest object:
update {[.hierarchies][hierarchy][ZEqi1GkByxIcUBtfsLRV], doc_as_upsert[false], doc[index {[null][null][null], source[{"errorMessages":"{\"isFavourite\":\"yes\",\"message\":\"hola\"}"}]}], scripted_upsert[false], detect_noop[true]}
Any idea about the problem?