I'm using hibernate search(latest release) with a local Lucene backend. I have two entities as follows;
@Entity
@Indexed
public class A {
@Id
private Long id;
@FullTextField
private String text;
@KeywordField
private String keyword;
}
@Entity
public class B {
private BigDecimal number;
@OneToOne
@JoinColumn(name = "a_id")
private A a;
}
I have mass indexer that handles indexing A entities at the application startup. While searching I want search results to be ordered by number field of entity B.
My search function is a simple boolean predicate as follows
.where(f -> f.bool()
.should(f.match().field("text").matching(query))
.should(f.match().field("keyword").matching(query.toUpperCase(Locale.ENGLISH)))
)
.fetch(offset, limit)
What should I do to order/boost search results depending on another field of another entity which has one-to-one relation?