spring数据ElasticSearch:索引字段必须是关键字而不是文本

yks3o0rb  于 2021-07-22  发布在  Java
关注(0)|答案(0)|浏览(188)

我有一个问题,我需要我的索引像这样:

"status": {
     "type": "keyword",
}

我创建java类:

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@Document(indexName = "#{applicationConfiguration.indexName}")
public class ProductDocument {

    @Field(type = FieldType.Keyword)
    @NotEmpty
    @JsonProperty("status")
    private String status;

}

但是spring创建的索引如下:

"status": {
     "type": "text",
     "fields": {
          "keyword": {
               "type": "keyword",
               "ignore_above": 256
          }
      }
}

如何使关键字类型成为主类型而不是文本?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题