我正在尝试禁用索引中一组字段的 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
, not date
.
所以我做了以下事情:
我创建了一个mappings.json
文件(见下文)并使用 @Mapping(mappingPath = "mappings.json") 注释
{
"date_detection": false
}
现在,这确实禁用了date_detection
但它也迫使updatedDate
属于类型text
这会导致一些错误。
这些是updatedDate
and customFields
我的索引类中的变量:
@Field(type = FieldType.Date, format = DateFormat.basic_date_time)
Instant updatedDate;
Map<String, Object> customFields;
有没有办法禁用date_detection
对于里面的字段customFields
这样只有dateOfBirth
字段的类型更改为text
并不是updatedDate
?