根据给定的输入查询对文本记录列表进行排名。
HTTP 请求
POST https://discoveryengine.googleapis.com/v1alpha/{rankingConfig=projects/*/locations/*/rankingConfigs/*}:rank
网址采用 gRPC 转码语法。
路径参数
参数 | |
---|---|
rankingConfig |
必需。排名服务配置的资源名称,例如 |
请求正文
请求正文中包含结构如下的数据:
JSON 表示法 |
---|
{
"model": string,
"topN": integer,
"query": string,
"records": [
{
object ( |
字段 | |
---|---|
model |
要使用的模型的标识符。它是以下之一:
如果未指定,则默认设置为 |
topN |
要返回的结果数。如果未设置或不大于零,则返回所有结果。 |
query |
要使用的查询。 |
records[] |
必需。要进行排名的记录列表。 |
ignoreRecordDetailsInResponse |
如果为 true,则响应将仅包含记录 ID 和得分。默认值为 false,响应将包含记录详细信息。 |
userLabels |
应用于资源的用户标签必须符合以下要求:
如需了解详情,请参阅 Google Cloud 文档。 |
响应正文
RankService.Rank
方法的响应消息。
如果成功,响应正文将包含结构如下的数据:
JSON 表示法 |
---|
{
"records": [
{
object ( |
字段 | |
---|---|
records[] |
按分数降序排序的记录列表。 |
授权范围
需要以下 OAuth 范围之一:
https://www.googleapis.com/auth/cloud-platform
https://www.googleapis.com/auth/discoveryengine.readwrite
如需了解详情,请参阅 Authentication Overview。
IAM 权限
需要拥有 rankingConfig
资源的以下 IAM 权限:
discoveryengine.rankingConfigs.rank
如需了解详情,请参阅 IAM 文档。
RankingRecord
针对 RankService.Rank
方法的记录消息。
JSON 表示法 |
---|
{ "id": string, "title": string, "content": string, "score": number } |
字段 | |
---|---|
id |
用于表示记录的唯一 ID。 |
title |
记录的标题。默认为空。应至少设置 |
content |
记录的内容。默认为空。应至少设置 |
score |
相应记录基于给定查询和所选模型的得分。得分将四舍五入到小数点后 2 位。如果得分接近 0,则会四舍五入为 0.0001,以避免返回未设置的值。 |