【发布时间】:2022-08-16 22:52:30
【问题描述】:
我试图在索引中的一组字段上禁用 date_detection。下面是映射
{
\"my-index\" : {
\"mappings\" : {
\"properties\" : {
\"_class\" : {
\"type\" : \"text\",
\"fields\" : {
\"keyword\" : {
\"type\" : \"keyword\",
\"ignore_above\" : 256
}
}
},
\"customFields\" : {
\"properties\" : {
\"firstName\" : {
\"type\" : \"text\",
\"fields\" : {
\"keyword\" : {
\"type\" : \"keyword\",
\"ignore_above\" : 256
}
}
},
\"lastName\" : {
\"type\" : \"text\",
\"fields\" : {
\"keyword\" : {
\"type\" : \"keyword\",
\"ignore_above\" : 256
}
}
},
\"address\" : {
\"type\" : \"text\",
\"fields\" : {
\"keyword\" : {
\"type\" : \"keyword\",
\"ignore_above\" : 256
}
}
},
\"dateOfBirth\" : {
\"type\" : \"date\"
}
}
},
\"key\" : {
\"type\" : \"long\"
},
\"updatedDate\" : {
\"type\" : \"date\",
\"format\" : \"basic_date_time\"
}
}
}
}
}
我希望dateOfBirth 字段的类型为text,而不是date。
所以我做了以下事情:
我创建了一个mappings.json 文件(见下文)并使用了@Mapping(mappingPath = \"mappings.json\") 注释
{
\"date_detection\": false
}
现在,这确实禁用了date_detection,但它也强制updatedDate 的类型为text,这会导致一些错误。
这些是我的索引类中的 updatedDate 和 customFields 变量:
@Field(type = FieldType.Date, format = DateFormat.basic_date_time)
Instant updatedDate;
Map<String, Object> customFields;
有没有办法为customFields 中的字段禁用date_detection,以便只有dateOfBirth 字段的类型更改为text 而不是updatedDate?
标签: elasticsearch elastic-stack spring-data-elasticsearch