You need to enable JavaScript to run this app.
文档中心
向量数据库VikingDB

向量数据库VikingDB

复制全文
下载 pdf
检索
检索公共参数
复制全文
下载 pdf
检索公共参数

检索功能由多个接口组成,分别对应不同的检索模式和业务场景。

接口说明

V2 接口将不同检索模式对应到不同的接口,更加清晰,便于您针对业务场景选择合适的检索方式。

检索类接口通用请求体参数
名称类型必选子参数类型描述
ResourceIDstring二选一Collection 的资源 ID。
CollectionNamestringCollection 名称。
IndexNamestring是索引名称。

OutputFields

[]string

否

要返回的标量字段列表。

  1. 未设置时返回集合内所有标量字段。
  2. 传入空列表表示不返回任何标量字段。
  3. 字段名必须存在于 collection schema,否则请求报错。
Filtermap[string]interface{}否标量过滤条件,格式见下文,默认不设置。
Limitint否返回结果上限,默认 10,最大值 100000。
Offsetint否分页偏移量,默认 0,过大时会触发深分页性能损耗。
Advance否DenseWeightfloat64混合向量场景下 dense / sparse 权重,默认 0.5,范围 [0.2, 1]。
IDsIn[]interface{}仅在该主键集合范围内检索。
IDsNotIn[]interface{}排除指定主键列表。
PostProcessOps[]map[string]interface{}后置处理算子列表,串行执行,详见《检索后处理算子-PostProcess》。
PostProcessInputLimitint进入后处理阶段的候选条数。
ScaleKfloat64分配给后续 rerank 的候选倍率。
FilterPreAnnLimitint先执行标量过滤时的最大候选条数。
FilterPreAnnRatiofloat64先执行标量过滤时的候选比例。

filter结构

使用 filter 的前提是,相应的标量字段已经设置为标量索引(scalar_index)。

算子适用字段类型说明示例

must

string、int64、bool、list

针对指定字段名生效,语义为必须在 [...] 之中,即 "must in"。

{
  "op": "must",
  "field": "region",
  "conds": ["cn", "sg"]
}

must_not

string、int64、bool、list

针对指定字段名生效,语义为必须不在 [...] 之中,即 "must not in"。

{
  "op": "must_not",
  "field": "data_type",
  "conds": [1, 2, 3]
}

and

/

逻辑算子,针对逻辑查询需求,对多个条件取交集。

{
  "op": "and", // 算子名
  "conds": [ // 条件列表,支持嵌套逻辑算子和 must/must_not 算子
    {
      "op": "must",
      "field": "type",
      "conds": [1]
    },
    {
      // 支持 >= 1 的任意数量的条件进行组合
    }
  ]
}

or

/

逻辑算子,针对逻辑查询需求,对多个条件取并集。

{
  "op": "or", // 算子名
  "conds": [ // 条件列表,支持嵌套逻辑算子和 must/must_not 算子
    {
      "op": "must",
      "field": "type",
      "conds": [1]
    },
    {
      // 支持 >= 1 的任意数量的条件进行组合
    }
  ]
}

range

int64、float32

针对指定字段名生效,语义为必须在指定范围内。配置使用 gte(大于等于)、gt(大于)、lte(小于等于)、lt(小于),用以圈定一维范围。

// price 在 [100.0, 500.0)
{
  "op": "range",
  "field": "price",
  "gte": 100.0,
  "lt": 500.0
}

// price >= 100.0
{
  "op": "range",
  "field": "price",
  "gte": 100.0
}

time_range

date_time

时间点筛选,配置使用 gte(大于等于)、gt(大于)、lte(小于等于)、lt(小于),用以圈定一维范围。

{
  // 检索北京时间 2025-08-12 00:00:00 ~ 2025-08-13 00:00:00 之间的数据
  "op": "time_range",
  "field": "f_date_time",
  "gt": "2025-08-12T00:00:00+08:00",
  "lt": "2025-08-13T00:00:00+08:00"
}

geo_range

geo_point

地理距离筛选,使用 center 为中心点,radius 为距离半径。

{
  "op": "geo_range",
  "field": "f_geo_point",
  "center": "116.412138,39.914912",
  "radius": "10000m"
}

后置处理结构

算子适用字段类型介绍示例

score_fusion

string

分数融合算子,用于融合指定的时空标量的分数。

{
  "op": "score_fusion",
  "fusion_by": "add",
  "addition_score_weight": 0.6, // 附加 score 的权重为 0.6,ANN score 的权重为 1 - 0.6 = 0.4
  "addition_score": [
    {
      "factor": 1.0,
      "base_value_from": "scalar_field",
      "field": "f_sales"
    },
    {
      "factor": -10.0, // 投诉多的商品,score 应该降低
      "base_value_from": "scalar_field",
      "field": "f_complain"
    }
  ]
}

string_contain

string

关键词匹配过滤算子。表示该字段内容包含 pattern。

{
  "op": "string_contain",
  "field": "name",
  "pattern": "bar"
}

string_match

string

正则匹配过滤算子。

{
  "op": "string_match",
  "field": "name",
  "pattern": "^[0-9A-Za-z_]+$"
}

enum_freq_limiter

string

频控算子。用于保证一次召回的结果中,一个特定取值出现的总数不超过 threshold 次。

{
  "op": "enum_freq_limiter",
  "field": "city",
  "threshold": 5
}

请求接口补充

适用接口

能力方法与路径
向量检索POST /api/vikingdb/data/search/vector
随机检索POST /api/vikingdb/data/search/random
关键词检索POST /api/vikingdb/data/search/keywords
ID 检索POST /api/vikingdb/data/search/id
标量排序检索POST /api/vikingdb/data/search/scalar
多模态检索POST /api/vikingdb/data/search/multi_modal

错误处理补充

错误码

本接口的业务错误码、触发条件和处理建议统一参见向量库 V2 错误码。排查时请同时记录响应中的 request_id,以便定位具体请求。

最近更新时间:2026.09.17 15:11:54
这个页面对您有帮助吗?
有用
有用
无用
无用