Weight
# code example
@Test
public void testWeight() throws IOException {
// test weight
LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();
String keyword = "Excellent";
float contentBoost = 5.0f;
wrapper.match(Document::getContent,keyword,contentBoost);
String creator = "Old man";
float creatorBoost = 2.0f;
wrapper.eq(Document::getCreator,creator,creatorBoost);
SearchResponse response = documentMapper.search(wrapper);
System.out.println(response);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
Tips
If you need a score, return it through SearchResponse. If you don't need a score, you only need to return it according to the ranking of the highest score, and you can directly use List<T>
to receive it.
Help us improve this document (opens new window)
Last update: 2024/03/29