排名评估
1.0 版引入
rank eval 端点允许您评估排序搜索结果的质量。
端点
GET <index_name>/_rank_eval
POST <index_name>/_rank_eval
查询参数
查询参数是可选的。
参数 | 数据类型 | 描述 |
---|---|---|
ignore_unavailable | 布尔型 | 默认为 false 。当设置为 false 时,如果索引已关闭或缺失,响应正文将返回错误。 |
allow_no_indices | 布尔型 | 默认为 true 。当设置为 false 时,如果通配符表达式指向已关闭或缺失的索引,响应正文将返回错误。 |
expand_wildcards | 字符串 | 展开通配符表达式以匹配 open 、closed 、hidden 、none 或 all 状态的索引。 |
search_type | 字符串 | 将搜索类型设置为 query_then_fetch 或 dfs_query_then_fetch 。 |
请求正文字段
请求正文必须至少包含一个参数。
字段类型 | 描述 |
---|---|
id | 文档或模板 ID。 |
requests | 在请求字段部分设置多个搜索请求。 |
ratings | 文档相关性分数。 |
k | 每个查询返回的文档数量。默认为 10。 |
relevant_rating_threshold | 文档被视为相关的阈值。默认为 1。 |
normalize | 设置为 true 时将计算折损累积增益。 |
maximum_relevance | 使用预期倒数排名指标时设置最大相关性分数。 |
ignore_unlabeled | 默认为 false 。设置为 true 时,未标记的文档将被忽略。 |
template_id | 模板 ID。 |
params | 模板中使用的参数。 |
请求示例
GET shakespeare/_rank_eval
{
"requests": [
{
"id": "books_query",
"request": {
"query": { "match": { "text": "thou" } }
},
"ratings": [
{ "_index": "shakespeare", "_id": "80", "rating": 0 },
{ "_index": "shakespeare", "_id": "115", "rating": 1 },
{ "_index": "shakespeare", "_id": "117", "rating": 2 }
]
},
{
"id": "words_query",
"request": {
"query": { "match": { "text": "art" } }
},
"ratings": [
{ "_index": "shakespeare", "_id": "115", "rating": 2 }
]
}
]
}
示例响应
{
"rank_eval": {
"metric_score": 0.7,
"details": {
"query_1": {
"metric_score": 0.9,
"unrated_docs": [
{
"_index": "shakespeare",
"_id": "1234567"
}, ...
],
"hits": [
{
"hit": {
"_index": "shakespeare",
"_type": "page",
"_id": "1234567",
"_score": 5.123456789
},
"rating": 1
}, ...
],
"metric_details": {
"precision": {
"relevant_docs_retrieved": 3,
"docs_retrieved": 6
}
}
},
"query_2": { [... ] }
},
"failures": { [... ] }
}
}