java - Hibernate Search vs Circular relationships -
good day.
i have situation, similar 1 presented below.
@entity @table(name="entitydo") public class entitydo { @id private long id; @column(nullable = false) private string name; @onetomany(mappedby = "parententity") private set<entitydo> ownedentities; @manytoone @joincolumn(name="parent_id", nullable=true) private entitydo parententity; ... } i need index entity via hibernate search in such way, there ability search entities matched not entity name, matching parent's name in hierarchy.
my thinking following:
i need recursively index 'name' member of indexed entity + 'name' of entity's parent + further etc. in such way came same lucene document's field.
then able create simple query on 1 field retrieve needed entities.
in fact, have problem point 1. @indexedembedded doesn't suit here, due circular relationship , fact empty prefixes forbidden (i don't want names of entities , parents in different fields).
is possible entity indexing in custom way? or maybe thinking wrong , there approach resolve such issues?
if want index parent name field name, write own custom bridge - http://docs.jboss.org/hibernate/stable/search/reference/en-us/html_single/#d0e4426. 1 thing have careful detect circular dependencies.
if have given max depth use @indexedembedded , @ query build time add query terms fields configured max depth. whether solution viable depend on how deep want index. jsut couple of levels prefer option on custom bridge.
Comments
Post a Comment