Java spring data elasticsearch是否支持将内部对象另存为新文档 @文档(indexName=“test”,type=“author”) 公共类作者{ 私有字符串编写器; 私人书目; } @文件(index name=“test”,type=“book”) 公共课堂用书{ 私有字符串bookId; }
使用spring data elasticsearch保存作者时,我希望该书保存在不同的实体中,而不是子文档中。可能吗?可以,但您需要存储图书ID而不是图书实体。非关系数据存储不支持像RDB这样的外键Java spring data elasticsearch是否支持将内部对象另存为新文档 @文档(indexName=“test”,type=“author”) 公共类作者{ 私有字符串编写器; 私人书目; } @文件(index name=“test”,type=“book”) 公共课堂用书{ 私有字符串bookId; },java,spring,
elasticsearch,spring-data,Java,Spring,
elasticsearch,Spring Data,使用spring data elasticsearch保存作者时,我希望该书保存在不同的实体中,而不是子文档中。可能吗?可以,但您需要存储图书ID而不是图书实体。非关系数据存储不支持像RDB这样的外键 @Document(indexName = "test", type = "author") public class Author { private String authorId; private List<Book> books; } @Document(inde
@Document(indexName = "test", type = "author")
public class Author {
private String authorId;
private List<Book> books;
}
@Document(indexName = "test", type = "book")
public class Book {
private String bookId;
}
@文档(indexName=“test”,type=“author”)
公共类作者{
私有字符串编写器;
私人列表图书ID;
}
此外,通过这样做,书籍不会与作者一起编入索引。如果您尝试搜索“编写具有特定标题的书籍的作者”,您将得到性能惩罚,而如果您嵌套它,ES将索引author.book.title
这个问题的答案很好
@Document(indexName = "test", type = "author")
public class Author {
private String authorId;
private List<String> bookIds;
}