从官方站点看英文,总结而来
原文链接:官方文档
Rank feature query,是用来计算相关性得分的,用于boo query里面的should clause。
Rank feature query必须基于rank_feature类型的field,而rank_feature字段必须基于rank_feature类型。
rank_feature 和 rank_features 是用于存储值的特殊类型字段,主要用于对结果进行评分。rank_feature 和 rank_features 中的值只能是单个正值(不允许有多个值)。 在 rank_features 的情况下,值必须是一个 hash 值,由一个字符串和一个正数值组成。
有一个标志可以改变评分的行为 — positive_score_impact。 该值默认为 true,但如果你希望该特征的值降低分数,你可以将其设置为 false。
mapping与数据的例子:
PUT /test
{
"mappings": {
"properties": {
"pagerank": {
"type": "rank_feature"
},
"url_length": {
"type": "rank_feature",
"positive_score_impact": false
},
"topics": {
"type": "rank_features"
}
}
}
}
PUT /test/_doc/1?refresh
{
"url": "https://en.wikipedia.org/wiki/2016_Summer_Olympics",
"content": "Rio 2016",
"pagerank": 50.3,
"url_length": 42,
"topics": {
"sports": 50,
"brazil": 30
}
}
GET /test/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"content": "2016"
}
}
],
"should": [
{
"rank_feature": {
"field": "pagerank"
}
},
{
"rank_feature": {
"field": "url_length",
"boost": 0.1
}
},
{
"rank_feature": {
"field": "topics.sports",
"boost": 0.4
}
}
]
}
}
}
Top-level parameters for rank_feature
field
(Required, string) rank_feature
or rank_features
field used to boost relevance scores.
boost
(Optional, float) Floating point number used to decrease or increase relevance scores. Defaults to 1.0
.
Boost values are relative to the default value of 1.0
. A boost value between 0
and 1.0
decreases the relevance score. A value greater than 1.0
increases the relevance score.
saturation
(Optional, function object) Saturation function used to boost relevance scores based on the value of the rank feature field
. If no function is provided, the rank_feature
query defaults to the saturation
function. See Saturation for more information.
Only one function saturation
, log
, sigmoid
or linear
can be provided.
log
(Optional, function object) Logarithmic function used to boost relevance scores based on the value of the rank feature field
. See Logarithm for more information.
Only one function saturation
, log
, sigmoid
or linear
can be provided.
sigmoid
(Optional, function object) Sigmoid function used to boost relevance scores based on the value of the rank feature field
. See Sigmoid for more information.
Only one function saturation
, log
, sigmoid
or linear
can be provided.
linear
(Optional, function object) Linear function used to boost relevance scores based on the value of the rank feature field
. See Linear for more information.
Only one function saturation
, log
, sigmoid
or linear
can be provided.
最后编辑:admin 更新时间:2023-11-29 18:18