elasticsearch 根据字段值添加查询时间权重/提升
我目前正在使用elasticsearch 2.4版,并希望根据我使用查询时间提升或权重调用的“类型”字段微调结果集 比如说 如果字段“type”的值为“shoots”,则添加权重或提升4 如果字段“type”的值为“Caravans”,则添加权重或提升3 从而使匹配查询字符串的船只出现在搜索结果中的商队之前
elasticsearch 根据字段值添加查询时间权重/提升,
elasticsearch,
elasticsearch,我目前正在使用elasticsearch 2.4版,并希望根据我使用查询时间提升或权重调用的“类型”字段微调结果集 比如说 如果字段“type”的值为“shoots”,则添加权重或提升4 如果字段“type”的值为“Caravans”,则添加权重或提升3 从而使匹配查询字符串的船只出现在搜索结果中的商队之前 我发现到目前为止我读过的关于过滤器、函数和函数分数的文档非常复杂。如果有人能为我的场景提供一个例子,我将不胜感激。您应该使用常量评分查询和提升选项来确定优先级 { "query": {
我发现到目前为止我读过的关于过滤器、函数和函数分数的文档非常复杂。如果有人能为我的场景提供一个例子,我将不胜感激。您应该使用
常量评分查询和提升
选项来确定优先级
{
"query": {
"bool": {
"should": [
{
"constant_score": {
"boost": 4,
"query": {
"match": {
"description": "Boats"
}
}
}
},
{
"constant_score": {
"boost": 3,
"query": {
"match": {
"description": "Caravans"
}
}
}
}
]
}
}
}
您应该使用constant_score
查询和boost
选项来确定优先级
{
"query": {
"bool": {
"should": [
{
"constant_score": {
"boost": 4,
"query": {
"match": {
"description": "Boats"
}
}
}
},
{
"constant_score": {
"boost": 3,
"query": {
"match": {
"description": "Caravans"
}
}
}
}
]
}
}
}
试试constant\u score
querytanks,很棒的答案试试constant\u score
querytanks,很棒的答案