首页 > 解决方案 > spring-data-elasticsearch - 当@Id 在同一字段上注释时,@Field 映射类型被忽略

问题描述

@Document(indexName = "opportunity_data", type = "opportunities", createIndex = false)
@Setting(settingPath = "/search/settings.json")
@Data
@Accessors(chain = true)
@JsonIgnoreProperties(value = {"id"}, allowGetters = true, allowSetters = false)
public class OpportunityVo extends AbstractGenericVo<Opportunity> {

  @Id
  @Field(type = FieldType.Long)
  private Long opportunityId;

  @Field(type = FieldType.Long)
  private Long prospectId;
  @Field(type = FieldType.Text)
  private String prospectName;
}

映射到关键字快照

opportunityId以上被映射到类型keyword以外long。由于我想在此属性上进行指标聚合,因此 任何人都知道如何在同时注释时将机会ID 映射到long类型?@Idstats

标签: elasticsearchspring-datamapping

解决方案


统计信息聚合只能应用于数字。更改映射工作正常。但是 @Id 将被映射到关键字,仍然没有运气。


推荐阅读