public class Product
{
public int ProductId { get; set; }
public string BrandName { get; set; }
public string Name { get; set; }
public ProductStatus ProductStatus { get; set; }
}
和ProductStatus枚举指定产品状态
public enum ProductStatus
{
Available = 1,
UnAvailable = 2,
CommingSoon = 3,
OutOfOrder = 4
}
我希望根据此订单对产品搜索结果进行排序:可用,CommingSoon,UnAvailable和OutOfOrder,此订单可能会稍后更改, 如何在elasticSearch和NEST中实现这种可能性
答案 0 :(得分:0)
我认为您可以对每个变量进行功能评分,然后对功能评分求和
function_score": {
"query": {},
"boost": "boost for the whole query",
"functions": [
{
"filter": {},
"FUNCTION": {},
"weight": number
},
{
"FUNCTION": {}
},
{
"filter": {},
"weight": number
}
],
"max_boost": number,
"score_mode": "(multiply|max|...)",
"boost_mode": "(multiply|replace|...)",
"min_score" : number
}