创建索引请求映射在弹性搜索中失败 [英] Create Index Request Mapping is failing in elastic search
本文介绍了创建索引请求映射在弹性搜索中失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在弹性搜索索引中创建Join数据类型,它正在从kibana控制台/通过rest运行,但是当我尝试以编程方式为索引创建映射时,它失败并出现以下错误,
I am trying to create the Join data type in the elastic search index, It is working from the kibana console / via rest but when I try to create the mapping for the index programmatically it fails with the below error,
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()具有以下映射:
where the inputObject.getMapping() has the following mapping :
{"mappings":{"properties":{"my_id":{"type":"keyword"},"my_join_field":{"type":"join","relations":{"question":"answer"}}}}}
推荐答案
您的inputObject.getMapping()
不应该包含mapping
部分.您可以在以下位置的inputObject.getMapping()
中进行更改吗?
Your inputObject.getMapping()
should not be having the mapping
part. Could you make the change in inputObject.getMapping()
you have from:
{"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"}}}}
让我知道是否可行.
这篇关于创建索引请求映射在弹性搜索中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文