Spring 数据 Elasticsearch 未将空值写入插入的文档
Spring Data Elasticsearch is not writing null values to inserted documents
我有一个 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 保留空值。
感谢您的宝贵时间!
由于无法对空值进行索引或搜索,因此 Spring Data Elasticsearch 通常不会存储它们,从而减小索引文档的大小。
不过,this issue 添加了存储空值的可能性,并将包含在明天发布的 4.1.RC1 版本中。
编辑: 4.1.0.RC1 现已发布
我有一个 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 保留空值。
感谢您的宝贵时间!
由于无法对空值进行索引或搜索,因此 Spring Data Elasticsearch 通常不会存储它们,从而减小索引文档的大小。
不过,this issue 添加了存储空值的可能性,并将包含在明天发布的 4.1.RC1 版本中。
编辑: 4.1.0.RC1 现已发布