0

我正在使用 Hibernate Search 自动更新 Lucene 索引,每次有新的照片实体进入时。当照片数据被保存或编辑时,它会很快自动进入索引。然而,当添加评论时,它永远不会进入。这正是@IndexedEmbedded/@ContainedIn应该做的,对吧?

我的代码大致如下:

@Indexed(index="/indexes/photo.index")
@Entity
public class Photo {

    @IndexedEmbedded
    @OneToMany(mappedBy="photo", fetch = FetchType.LAZY)
    public List<Comment> comments;

}

@Indexed(index="indexes/comment.index")
@Entity
public class Comment {

    @ContainedIn
    @ManyToOne
    public Photo photo;

    @Field
    public String text;
}

我正在使用以下库版本:

hibernate-search-3.4.0.Final
lucene-core-3.6.0
lucene-analyzers-3.1.0

注意:对于那些马上跳起来的人,说我弄乱了这两个注释的顺序,我会说我也尝试过相反的方法。不工作。

4

1 回答 1

0

版本 3.4.0.Final 是第一个包含脏检查优化的版本,这在以后的版本中变得更加稳定。您可以尝试设置 Hibernate 配置属性吗

hibernate.search.enable_dirty_check=false

确保此类优化不会影响您。

此外,请使用为此版本设计的 Lucene 版本,否则您可能会遇到任何问题:

lucene-core-3.1.0
lucene-analyzers-3.1.0
于 2013-08-13T20:22:14.147 回答