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实例
最新推荐文章于 2025-03-18 15:32:09 发布