在弹性搜索休息高级客户端中出现以下错误

Getting below error in elastic search rest high level client

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

Elasticsearch exception [type=mapper_parsing_exception, reason=Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [recommendations : {recommendations={properties={events={type=nested, properties={recommendationData={type=nested, properties={recommendations={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"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}