以前我使用的是elasticsearch 2.2,现在我已经升级到elasticsearch 5.1及以下版本是获取传输客户端对象的代码,但面临一个问题。
Settings settings = Settings.builder().put("cluster.name",
elasticConfiguration.getProperty("cluster.name", "elasticsearch")).
put("client.transport.sniff", true).
build();
TransportClient client = new PreBuiltTransportClient(settings);
for(InetSocketTransportAddress address:nodes){
(client).addTransportAddress(address);
}
SearchResponse response = null;
try {
LOG.debug("search query "+queryBuilder);
response = client.prepareSearch(CampaignRepository.INDEX_NAME)
.setTypes(getTypeName()).setQuery(queryBuilder).execute()
.get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error searching result for " + queryBuilder
+ " Error message " + e.getMessage());
// e.printStackTrace();
throw new CampaignSystemException();
}
但它给了我一个错误,
java.util.concurrent.ExecutionException: SendRequestTransportException[[dHFgT6l][10.10.2.231:9300][indices:data/read/search]]; nested: IOException[can not write type [class com.seamless.ers.campaignsystem.api.model.campaign.CampaignState]];
其中CampaignState是枚举
请帮助!!
答案 0 :(得分:1)
在做了一些R& D之后,发现有一个关于elasticsearch的错误。在ES 2.2中,它用于接受枚举并将其转换为字符串,但在5.1中同样没有发生,这可能会在即将发布的版本中得到修复