【问题标题】:Spring Data Elasticsearch is not writing null values to inserted documentsSpring Data Elasticsearch 不会将空值写入插入的文档
【发布时间】:2020-09-14 23:15:34
【问题描述】:

我有一个 ES 实体:

@Document(indexName = "company")
public class CompanyEntity {

  @MultiField(
      mainField = @Field(type = Text, name = "alias_name"),
      otherFields = {@InnerField(suffix = "keyword", type = Keyword, nullValue = "NULL")})
  @Nullable
  private String aliasName;

 ...
}

如果我创建一个 CompanyEntity 对象并且不提供别名,我的期望是 Spring Data Elasticsearch 将为 Nullable 的实体属性保留空值。但情况似乎并非如此,即使我在 InnerField 注释中为 nullValue 提供了一个值。

我确定我错误地配置了注释或其他东西,但我真的很想使用 Elasticsearch 的 null_value 参数作为详细的 here。但首先我需要了解如何让 SDE 保持空值。

感谢您的宝贵时间!

【问题讨论】:

    标签: java spring elasticsearch spring-data spring-data-elasticsearch


    【解决方案1】:

    由于 null 值无法被索引或搜索,它们通常不会被 Spring Data Elasticsearch 存储,从而减少了索引文档的大小。

    this issue 添加了存储空值的可能性,并将包含在明天应该发布的版本 4.1.RC1 中。

    编辑: 4.1.0.RC1 现已发布

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-28
      • 2016-05-15
      • 2014-09-08
      • 1970-01-01
      • 2022-01-13
      • 2018-08-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多