client = ESUtils.ES_UTILS.getClient();
XContentBuilder builder= XContentFactory.jsonBuilder()
.startObject()
.startObject(type)
.startObject("properties")
.startObject("user")
.field("type","string")
.field("index","not_analyzed")
.endObject()
.startObject("postDate")
.field("type","date")
.endObject()
.startObject("message")
.field("type","string")
.field("index","not_analyzed")
.endObject()
.startObject("address")
.field("type","string")
.endObject()
.startObject("车牌号")
.field("type","string")
.field("index","ik")
.endObject()
.endObject()
.endObject();
String mappingStr=builder.string();
client.admin().indices().prepareCreate(indexName).addMapping(type,mappingStr).setSettings(settings).execute();
因为后续索引字段还要增多,怎么通过for循环构建索引的mapping结构?
2 个回复
jianjianhe
赞同来自:
lrc
赞同来自:
1,nested类型,如何通过你的方法进行创建?
2,你的方法参数中的Map结构是怎样的?是否可提供调用范例?
谢谢您的答复!