How to score results ES 2.1 (java client)


(Gabriel Kälin) #1

I try to score my resultset on a field if any of the other queries match.

Pre 2.1 I scored my results with a FilterBuilder.

FunctionScoreQueryBuilder scoredQuery = QueryBuilders.functionScoreQuery(baseQuery)
.add(FilterBuilders.termFilter("some_field", "123"), ScoreFunctionBuilders.weightFactorFunction(10f));

this added a boost to all results that matched the fields. Now I have trouble to find a solution for 2.1.

Everything I tried either

  • added the items to the top of my list regardless if any other query matches
    or
  • showed only those results that matched my scoring query

Am I missing something?

Help is greatly appreciated.


(system) #2