我使用function_score根据过滤条件计算重量,我有很多过滤条件,是否有相应的动态方法来添加过滤器和权重?
var functions = new List<Func<FunctionScoreFunctionsDescriptor<ResidentialDetails>, FunctionScoreFunction<ResidentialDetails>>>();
var scaleDaysForSorting = 12d;
functions.Add(fn => fn.Gauss(g => g.DateCreated, g => g.Scale(scaleDaysForSorting))
.Weight(8.5)
.Filter(f =>
{
return filters[term] && filters[refine] && filters[standard] && filters[imageExists];
}));
functions.Add(fn => fn.Gauss(g => g.DateCreated, g => g.Scale(scaleDaysForSorting))
.Weight(8)
.Filter(f =>
{
return filters[term] && filters[refine] && filters[standard] && filters[imageDoesNotExists];
}));
functions.Add(fn => fn.Gauss(g => g.DateCreated, g => g.Scale(scaleDaysForSorting))
.Weight(7.5)
.Filter(f =>
{
return filters[term] && filters[refine] && filters[premium] && filters[imageExists];
}));
functions.Add(fn => fn.Gauss(g => g.DateCreated, g => g.Scale(scaleDaysForSorting))
.Weight(7)
.Filter(f =>
{
return filters[term] && filters[refine] && filters[premium] && filters[imageDoesNotExists];
}));
functions.Add(fn => fn.Gauss(g => g.DateCreated, g => g.Scale(scaleDaysForSorting))
.Weight(6.5)
.Filter(f =>
{
return filters[term] && filters[refine] && filters[unclaimed] && filters[imageExists];
}));