我正在尝试更新elasticsearch中的对象,但我收到了下一条错误消息:
Elasticsearch异常[type=mapper_parsing_exception,errorMessages的reason=object映射尝试将字段errorMessages解析为对象,但找到了具体的值]
This is my mappings:
{
.hierarchies: {
mappings: {
hierarchy: {
dynamic: "strict",
_all: {
enabled: false
},
properties: {
errorFlag: {
type: "keyword"
},
errorMessages: {
properties: {
isFavourite: {
type: "text"
},
message: {
type: "text"
}
}
},
}
}
}
我要更新的信息是这样的:
"errorMessages" -> "{"isFavourite":"yes","message":"hola"}"
我使用rest客户端连接器和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() + ")");
}
}
文档的值是带有errorMessages的json。这是UpdateRequest对象:
索引更新{ source{"errorMessages":"{\"isFavourite\":\"yes\",,
,doc[.hierarchiesZEqi1GkByxIcUBtfsLRV {nullnull,doc_as_upsertfalse \“\”:\“hola\”}“}}],scripted_upsertfalse,detect_nooptrue}
对这个问题有什么想法吗?
发布于 2019-04-01 11:16:32
errorMessages
应该表示为对象数组,如下所示,而不是字符串值:
{
"errorMessages": [
{
"isFavourite": "yes",
"message": "hola"
}
]
}
https://stackoverflow.com/questions/55443666
复制相似问题