Thank you for the answer. Sorry for not posting the code: it is 1:M bidirectional relation between Order and Item, and you can search Order by Item name (sorry if this requirement looks weird, we really though it through, but it's a simplified example).
@Indexed @Entity(...) class Order{ @Id @DocumentId private int id; @Field @Column private String orderName; @OneToMany(...) @IndexEmbedded private List<Items> items = new ArrayList(); @Column private long modified; }
@Indexed (...) class Item { @Id @DocumentId private int id; @Field @Column private String itemName; @ManyToOne(...) @ContainedIn private Order parentOrder; @Column private long modified; }
To your question - we chose daily reindex because we have good experience with it (from before we migrated to Hibernate search). Our users do lots of inserts (more than the traditional example of "online store"), and need it to be fast, while we don't care that much about stale data.
The problem is, if you modify a single item, the item is marked as modified, but the parent Order keeps the old timestamp. So if I reindex Orders, it's not enough to select "Orders that were modified today"... I need "Orders that were modified themselves, or that contain modified items". I though maybe other people ran into this problem (everyone who does manual reindexing on 1:M relations)... and whether there are utilities or "best practices" for it.
Thank you .
|