I spent much time to try the new Elasticsearch Java client 7.16.3, but it is hard for me to use it, such as must
, terms
, multi_match
, functions
, filter
and so on. Can someone please help me in building the query as blow using the new Elasticsearch Java client, complete Java code or snippet will be better, thx
{
"query": {
"function_score": {
"query": {
"bool": {
"must": [
{
"terms": {
"type": [
1,
2
]
}
},
{
"multi_match": {
"query": "facebook",
"fields": [
"title",
"content",
"stockCodes",
"stockNames"
]
}
}
],
"boost": 1
}
},
"functions": [
{
"filter": {
"terms": {
"type": [
1,
2
]
}
},
"weight": 1
},
{
"filter": {
"match": {
"title": "facebook"
}
},
"weight": 100
},
{
"filter": {
"match": {
"stockCodes": "facebook"
}
},
"weight": 10
},
{
"filter": {
"match": {
"stockNames": "facebook"
}
},
"weight": 10
},
{
"filter": {
"match": {
"content": "facebook"
}
},
"weight": 5
}
],
"score_mode": "sum",
"boost_mode": "multiply",
"max_boost": 120,
"boost": 1
}
},
"sort": [
{
"_score": {
"order": "desc"
}
},
{
"releaseTime": {
"order": "desc"
}
}
],
"from": 0,
"size": 9
}
such as, i cannot find the api to set the value of terms