如何使用客户端elastic4s scala创建查询?
我用marvel / sense打电话
GET /business/_search
{
"query": {
"function_score": {
"query": {
"match": {
"name": "my text"
}
},
"script_score": {
"script": "_score + log(doc['reviews'].value + 1 )",
"lang": "groovy"
}
}
},
"facets": {
"industry": {
"terms": {
"fields": ["type", "industry"]
}
}
},
"size": 10
}
但我如何使用elastic4s创建查询?
答案 0 :(得分:2)
您可以执行以下功能评分查询:
val req = search in "marvel/sense" query {
functionScoreQuery(matchQuery("name", "my_text")).scorers(
scriptScore("_score + log(doc['reviews'].value + 1 )")
)
}
然后当然按照https://github.com/sksamuel/elastic4s/blob/master/guide/search.md
中的说明添加方面等