Hi,
I have a FullTextQuery against the following classes
Code:
@Entity
@Indexed
Post
@OneToMany
List<Comment> comments
@Entity
@Indexed
Comment
@ManyToOne
@ContainedIn
Post post;
Since I'm always only interested in reading only
one comment with a post, I don't use @IndexedEmbedded on the Post.comments field. Adding it would needlessly grow the Post index. In stead I use a classbridge for this.
I do want to query comments by Post.
Code:
FullTextSession fts = Search
.getFullTextSession(getHibernateTemplate()
.getSessionFactory().getCurrentSession());
QueryBuilder qb = fts.getSearchFactory().buildQueryBuilder()
.forEntity(Comment.class).get();
Query q = qb.bool().must(
qb.keyword().onField("post.id").matching(postId).createQuery()
).createQuery();
FullTextQuery ftq = fts.createFullTextQuery(q, Comment.class)
.setFirstResult(start)
.setMaxResults(max);
However, I get this error:
Unable to find field post in Comment.
Adding a classbridge to add the missing field, doesn't help because up to HSearch 4.0, fields added in classbridges are invisible to HSearch. Not even sure, if this has changed when it comes to querying on fields in stead of projecting.
Adding a fieldbridge on the field also doesn't seem to help.
Any ideas on how to accomplish the select in HSearch 3.4?
Kind regards,
Marc