如何在 Spring data cloud 数据存储中将引用标记为未索引
我们有 @Unindexed 注释来将字段标记为未索引。但它不适用于引用类型字段。 来源:- https://cloud.spring.io /spring-cloud-static/Greenwich.RC1/multi/multi__spring_data_cloud_datastore.html
@Entity(name = "kind_one")
class Test {
@Unindexed
private String someFieldOne; //works - property is unindexed
@Unindexed
private List<TestTwo> someFieldTwo; //doesn't work - property is still indexed
}
@Entity(name = "kind_two")
class TestTwo{
@Unindexed
private String someFieldThree;
}
将 Test 对象存储在数据存储中时,“someFieldOne”被标记为未索引,但“someFieldTwo”被标记为已索引。
任何线索将不胜感激。
谢谢!
We have @Unindexed annotation to mark a field as unindexed. But it doesn't work with a reference type field.
Source:- https://cloud.spring.io/spring-cloud-static/Greenwich.RC1/multi/multi__spring_data_cloud_datastore.html
@Entity(name = "kind_one")
class Test {
@Unindexed
private String someFieldOne; //works - property is unindexed
@Unindexed
private List<TestTwo> someFieldTwo; //doesn't work - property is still indexed
}
@Entity(name = "kind_two")
class TestTwo{
@Unindexed
private String someFieldThree;
}
When storing the Test object in datastore, "someFieldOne" is marked as unindexed, but "someFieldTwo" is marked as indexed.
Any lead will be appreciated.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于列表,不得将整个列表排除在索引之外,而是必须将其值单独排除在索引之外,如注释 此处。否则会抛出异常。
我相信这就是为什么
someFieldTwo
在您的情况下被索引的原因,因为它是一个列表,除非它应该根据注释抛出异常。因此,我建议您按照此示例 而不是用
@unindexed
注释整个列表。For Lists the entire list must not be excluded from being indexed instead its values must be individually excluded from being indexed as mentioned in the comments here. Otherwise it will throw an exception.
I believe this is the reason why
someFieldTwo
is getting indexed in your case as it is a List barring the fact that it should throw an exception as per the comment.So I would suggest you exclude the list elements individually as mentioned in this example instead of annotating the whole list with
@unindexed
.