| Now that Index time indexing is deprecated I'm trying to move to query time boosting but I'm not able to properly build an query. The issue is that my query is dynamically built and I have a list of individual fields and their boost values. For example Name : Boost 10f Legal Name: Boost 1.5f Description: Boost 0f I have a class below which I use to store field name and boost value
public class IndexedField {
private final String name;
private final float boost;
private IndexedField(String name, float boost) {
this.name = name;
this.boost = boost;
}
public String getName() {
return name;
}
public float getBoost() {
return boost;
}
public static IndexedField create(String name, float boost) {
return new IndexedField(name, boost);
}
}
What is really need is to be able to loop through my fields that I want to query and their boost value like below I cannot however find a way to add individual fields to query each with independent query values. Something like the below.
FullTextEntityManager fullTextEntityManager = org.hibernate.search.jpa.Search.getFullTextEntityManager(em);
QueryBuilder builder = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity(IndexedEntity.class).get();
TermContext ctx = builder.keyword();
for(IndexedField field : indexedFields){
ctx.onFieldWithBoost(field.getName(), field.getBoost());
}
|