【发布时间】:2018-12-04 09:08:53
【问题描述】:
In Elasticsearch Document描述函数分数查询显示代码如下
GET /_search
{
"query": {
"function_score": {
"query": { "match_all": {} },
"boost": "5",
"functions": [
{
"filter": { "match": { "test": "bar" } },
"random_score": {},
"weight": 23
},
{
"filter": { "match": { "test": "cat" } },
"weight": 42
}
],
"max_boost": 42,
"score_mode": "max",
"boost_mode": "multiply",
"min_score" : 42
}
}
}
我将此查询写给object initializer syntax
var searchRequest = new SearchRequest<ProductType>
{
Query = new FunctionScoreQuery()
{
Query = new MatchAllQuery {},
Boost = 5,
Functions = new List<IScoreFunction>
{
Filters...?
},
MaxBoost = 42,
ScoreMode = FunctionScoreMode.Max,
BoostMode = FunctionBoostMode.Max,
MinScore = 42
}
};
如何在函数中构建过滤器?
IScoreFunction 接口只允许ExponentialDecayFunction、GaussDateDecayFunction、LinearGeoDecayFunction、FieldValueFactorFunction、RandomScoreFunction、WeightFunction、ScriptScoreFunction
【问题讨论】:
标签: c# .net elasticsearch nest elasticsearch.net