我正在尝试使用Java客户端在弹性搜索中为某种类型创建映射,因为某些原因我在检查索引时不应用映射。我的代码如下所示:
XContentBuilder settingsBuilder = jsonBuilder()
.startObject()
.startObject("analysis")
.startObject("analyzer")
.startObject("default")
.field("type", "pattern")
.field("pattern", " ")
.field("lowercase", false)
.endObject()
.endObject()
.endObject()
.endObject();
XContentBuilder mappingBuilder = jsonBuilder()
.startObject()
.startObject(ELASTIC_PROFILE_TYPE)
.startObject("properties")
.startObject(ELASTIC_ALL_FIELD_BOOL)
.field("type", "text")
.field("similarity", "boolean")
.endObject()
.endObject()
.endObject()
.endObject();
indices.prepareCreate(this.index)
.setSettings(settingsBuilder)
.addMapping(ELASTIC_PROFILE_TYPE, mappingBuilder)
.get();
GetFieldMappingsResponse getFieldMappingsResponse = indices.prepareGetFieldMappings(this.index).setTypes(ELASTIC_PROFILE_TYPE).get();
System.out.println(getFieldMappingsResponse.mappings());
但我得到以下结果:
{barista_test={}}
知道我做错了吗?