es java api 创建索引结构_elasticsearch - 如何使用ES的Java API来创建一个新类型的索引 - SO中文参考 - www.soinside.com...
我已經成功創建索引的使用客戶,這樣的代碼:
public static boolean addIndex(Client client,String index) throws Exception {
if(client == null){
client = getSettingClient();
}
CreateIndexRequestBuilder requestBuilder = client.admin().indices().prepareCreate(index);
CreateIndexResponse response = requestBuilder.execute().actionGet();
return response.isAcknowledged();
//client.close();
}
public static boolean addIndexType(Client client, String index, String type) throws Exception {
if (client == null) {
client = getSettingClient();
}
TypesExistsAction action = TypesExistsAction.INSTANCE;
TypesExistsRequestBuilder requestBuilder = new TypesExistsRequestBuilder(client, action, index);
requestBuilder.setTypes(type);
TypesExistsResponse response = requestBuilder.get();
return response.isExists();
}
然而,addIndex類型的方法不受影響,類型不創建。
我不知道如何創建類型?
總結
以上是生活随笔為你收集整理的es java api 创建索引结构_elasticsearch - 如何使用ES的Java API来创建一个新类型的索引 - SO中文参考 - www.soinside.com...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 我的世界java什么村民卖地图_《我的世
- 下一篇: 链表队列入门介绍