繁体   English   中英

创建索引请求映射在弹性搜索中失败

[英]Create Index Request Mapping is failing in elastic search

我正在尝试在弹性搜索索引中创建 Join 数据类型,它正在从 kibana 控制台/通过 rest 工作,但是当我尝试以编程方式为索引创建映射时,它失败并出现以下错误,

java.util.concurrent.ExecutionException: RemoteTransportException[[3cfb4e163654][172.17.0.2:9300][indices:admin/create]]; nested: MapperParsingException[Failed to parse mapping [properties]: Root mapping definition has unsupported parameters:  [my_join_field : {type=join, relations={question=answer}}] [my_id : {type=keyword}]]; nested: MapperParsingException[Root mapping definition has unsupported parameters:  [my_join_field : {type=join, relations={question=answer}}] [my_id : {type=keyword}]];

映射:

{
    "properties": {
      "my_id": {
        "type": "keyword"
      },
      "my_join_field": { 
        "type": "join",
        "relations": {
          "question": "answer" 
        }
      }
    }
  }

代码:

public void createIndex(ReIndex indexObject) throws XXXDefinedException {
        String index = indexObject.getDestinationIndex();
        try {
            LOG.info("Initiating the index creation process for the " + index);
            CreateIndexRequest request = new CreateIndexRequest(index);
            if (!CommonUtils.isEmptyMap(indexObject.getMapping())) {
                LOG.info("Index Mapping Available : " + index);
                String indexMapping = new GsonBuilder().create().toJson(indexObject.getMapping());
                request.source(indexMapping, XContentType.JSON);
            }
            AcknowledgedResponse indexResponse = client.admin().indices().create(request).get();
            client.admin().indices().prepareRefresh().execute().actionGet();
            LOG.info("Index is created successfully : " + indexResponse);
        } catch (Exception e) {
            throw new XXXDefinedException (e);
        }
    }

其中 inputObject.getMapping() 具有以下映射:

  {"mappings":{"properties":{"my_id":{"type":"keyword"},"my_join_field":{"type":"join","relations":{"question":"answer"}}}}}

您的inputObject.getMapping()不应该有mapping部分。 您能否在inputObject.getMapping()中进行更改:

{"mappings":{"properties":{"my_id":{"type":"keyword"},"my_join_field":{"type":"join","relations":{"question":"answer"}}}}}

{"properties":{"my_id":{"type":"keyword"},"my_join_field":{"type":"join","relations":{"question":"answer"}}}}

让我知道这是否可行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM