We're updating the issue view to help you get more done. 

Support for Field and Boost at Query Time

Description

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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.

1 2 3 4 5 6 7 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()); }

Environment

None

Status

Assignee

Yoann Rodière

Reporter

Cody Lerum

Labels

None

Suitable for new contributors

None

Pull Request

None

Feedback Requested

None

Components

Affects versions

5.10.3.Final

Priority

Major