I'm using spring boot with the Spring Data Elastic search client.
And I have something like
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder();
QueryBuilder nameQuery = boolQuery().should(matchQuery("fullName", queryText)).boost(10)
.should(matchQuery("fullName", queryText).fuzziness(Fuzziness.ONE)).boost(1.5f)
.should(matchQuery("fullName.autocomplete", queryText)).boost(2f)
.should(matchQuery("fullName.metaphone", queryText)).boost(1.2f)
.should(matchQuery("fullName.synonym", queryText)).boost(2)
.should(matchQuery("fullName.porter", queryText));
searchQueryBuilder.withQuery(nameQuery);
List<MasterIndex> masterIndices = masterIndexRepository.search(searchQueryBuilder.build());
After getting all of the names, I'd like to try with rescoring using some other attributes to reorder the result that might be more relevant. I know there is a rescore query, like this
RescoreBuilder.QueryRescorer rescoreBuilder = RescoreBuilder.queryRescorer(boolQuery().should(hasChildQuery("client",
QueryBuilders.boolQuery()
.should(QueryBuilders.termsQuery("enrollments.programId", programId))
))).setQueryWeight(0.7f).setRescoreQueryWeight(0.3f);
But how to put the rescoreBuilder together with NativeSearchQueryBuilder?
Or if there's any other way to customize score and order the result more intelligently, please let me know.