在弹性搜索rest高级客户端中获取以下错误



当我尝试使用create index请求创建映射时,出现以下错误。

Elasticsearch异常[类型=mapper_parsing_exception,原因=失败要分析映射[_doc]:不支持根映射定义参数:[建议:{推荐={属性={事件={类型=嵌套,properties={recommendationData={type=nested,properties={recommendance={type=nested,properties={recommendationType={type=keyword=

并且映射是

{
"mappings": {
"recommendations": {
"properties": {
"events": {
"type": "nested",
"properties": {
"recommendationData": {
"type": "nested",
"properties": {
"recommendations": {
"type": "nested",
"properties": {
"recommendationType": {
"type": "keyword"
}
}
}
}
}
}
}
}
}
}
}

java代码是

private void checkAndCreateDocumentMapping() throws IOException {
CreateIndexRequest createIndexRequest = new CreateIndexRequest(this.getIndexName());
String indexString = getStringFromFile("nested" + ".mapping");
createIndexRequest.source(indexString, XContentType.JSON);
client.indices().create(createIndexRequest, RequestOptions.DEFAULT);
}
请注意,elasticsearch不再支持多个映射,因此不再需要传递映射名称。假设recommendations是映射的名称,则可以将其用作索引的名称。因此,创建索引的正确dsl应该是,
PUT recommendations
{
"mappings": {
"properties": {
"events": {
"type": "nested",
"properties": {
"recommendationData": {
"type": "nested",
"properties": {
"recommendations": {
"type": "nested",
"properties": {
"recommendationType": {
"type": "keyword"
}
}
}
}
}
}
}
}
}
}

相关内容

  • 没有找到相关文章

最新更新