try {
CreateIndexRequestBuilder cib = client.admin().indices().prepareCreate(index);
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("properties");
mapping.startObject(field).field("type", "long").field("index", "not_analyzed").endObject();
mapping.endObject().endObject();
cib.addMapping(type, mapping);
cib.execute().actionGet();
} catch (ProcessClusterEventTimeoutException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
创建Index实例
最新推荐文章于 2024-06-26 22:41:50 发布