简体   繁体   English

Spring elasticsearch - Map<string, string> 指数</string,>

[英]Spring elasticsearch - Map<String, String> index

I have an object that contains a Map<String, String> field:我有一个 object,其中包含一个 Map<String, String> 字段:

@Document(indexName = "custom-creative-template")
@Setting(settingPath = "/elasticsearch/custom-creative-template-index.json")
public class CustomCreativeTemplateIndexDto {
    Map<String, String> customValues;
}

When querying data for this index, I am getting the following error:查询此索引的数据时,出现以下错误:

org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for type java.lang.String!

When using Map<String, Object> however, it works.但是,当使用 Map<String, Object> 时,它可以工作。

That's the Settings file for the index:这是索引的Settings文件:

{
  "index": {
    "analysis": {
      "normalizer": {
        "sortable": {
          "filter": [
            "lowercase"
          ]
        }
      }
    }
  }
}

I have tried setting the FieldType in the Field annotation to FieldType.Text & FieldType.Flattened but I keep getting the same error.我尝试将Field注释中的FieldType设置为FieldType.Text & FieldType.Flattened但我一直收到相同的错误。

Mappings : 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"
            }
          }
        }
      }
    }
  }
}

Works for me with field type object:适用于字段类型 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM