弹性搜索中的错误低于高级客户端

时间:2020-04-15 03:58:58

标签: java elasticsearch elastic-stack resthighlevelclient

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

Elasticsearch异常[type = mapper_parsing_exception,原因=失败 解析映射[_doc]:根映射定义不受支持 参数:[建议: {recommendations = {properties = {events = {type = nested, 属性= {recommendationData = {类型=嵌套, 属性= {建议= {类型=嵌套, 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);
    }

1 个答案:

答案 0 :(得分:0)

请注意,elasticsearch不再支持多个映射,因此不再需要传递映射名称。假设const add = (amount) => (item) => item + amount; console.log([1,2,3,4,5,6].map(add(100)));是映射名称,则可以将其用作索引名称。因此,正确的dsl创建索引应该是

recommendations