搜索模型
您可以使用此命令搜索已创建的模型。
响应将只包含您有权访问的模型版本。例如,如果您发送一个 match_all
查询,将返回以下模型组类型的模型版本
- 索引中的所有公共模型组
- 您是模型所有者的私有模型组
- 与您的后端角色共享至少一个后端角色的模型组
有关此 API 的用户访问信息,请参阅模型访问控制注意事项。
端点
GET /_plugins/_ml/models/_search
POST /_plugins/_ml/models/_search
示例请求:搜索所有模型
POST /_plugins/_ml/models/_search
{
"query": {
"match_all": {}
},
"size": 1000
}
示例请求:搜索使用算法“FIT_RCF”的模型
POST /_plugins/_ml/models/_search
{
"query": {
"term": {
"algorithm": {
"value": "FIT_RCF"
}
}
}
}
示例:排除模型块
GET /_plugins/_ml/models/_search
{
"query": {
"bool": {
"must_not": {
"exists": {
"field": "chunk_number"
}
}
}
},
"sort": [
{
"created_time": {
"order": "desc"
}
}
]
}
示例:搜索所有模型块
以下查询将搜索 ID 为 979y9YwBjWKCe6KgNGTm
的模型的全部块,并按升序排序这些块
GET /_plugins/_ml/models/_search
{
"query": {
"bool": {
"filter": [
{
"term": {
"model_id": "9r9w9YwBjWKCe6KgyGST"
}
}
]
}
},
"sort": [
{
"chunk_number": {
"order": "asc"
}
}
]
}
示例:按描述搜索模型
GET _plugins/_ml/models/_search
{
"query": {
"bool": {
"should": [
{
"match": {
"description": "sentence transformer"
}
}
],
"must_not": {
"exists": {
"field": "chunk_number"
}
}
}
},
"size": 1000
}
示例响应
{
"took" : 8,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 2.4159138,
"hits" : [
{
"_index" : ".plugins-ml-model",
"_id" : "-QkKJX8BvytMh9aUeuLD",
"_version" : 1,
"_seq_no" : 12,
"_primary_term" : 15,
"_score" : 2.4159138,
"_source" : {
"name" : "FIT_RCF",
"version" : 1,
"content" : "xxx",
"algorithm" : "FIT_RCF"
}
},
{
"_index" : ".plugins-ml-model",
"_id" : "OxkvHn8BNJ65KnIpck8x",
"_version" : 1,
"_seq_no" : 2,
"_primary_term" : 8,
"_score" : 2.4159138,
"_source" : {
"name" : "FIT_RCF",
"version" : 1,
"content" : "xxx",
"algorithm" : "FIT_RCF"
}
}
]
}
}