![](/img/trans.png)
[英]spring elasticsearch : how to save Map as string in index?
[英]Spring elasticsearch - Map<String, String> index
我有一个 object,其中包含一个 Map<String, String> 字段:
@Document(indexName = "custom-creative-template")
@Setting(settingPath = "/elasticsearch/custom-creative-template-index.json")
public class CustomCreativeTemplateIndexDto {
Map<String, String> customValues;
}
查询此索引的数据时,出现以下错误:
org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for type java.lang.String!
但是,当使用 Map<String, Object> 时,它可以工作。
这是索引的Settings
文件:
{
"index": {
"analysis": {
"normalizer": {
"sortable": {
"filter": [
"lowercase"
]
}
}
}
}
}
我尝试将Field
注释中的FieldType
设置为FieldType.Text
& FieldType.Flattened
但我一直收到相同的错误。
Mappings
:
{
"custom-creative-template": {
"mappings": {
"properties": {
"_class": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"customValues": {
"properties": {
"offerBullets": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"offerDescription": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"key": {
"type": "long"
},
"name": {
"type": "text",
"fields": {
"sort": {
"type": "keyword",
"normalizer": "sortable"
}
}
}
}
}
}
}
适用于字段类型 object 的我:
@Document(indexName = "custom-creative-template")
@Setting(settingPath = "/elasticsearch/custom-creative-template-index.json")
public class CustomCreativeTemplateIndexDto {
@Field(type = FieldType.Object)
Map<String, String> customValues;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.