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

向量数据库VikingDB

复制全文
下载 pdf
文档(Doc)
get_doc
复制全文
下载 pdf
get_doc
概述

get_doc 用于查看知识库下的文档信息。

请求参数
参数类型是否必选默认值参数说明
collectionNameString否--知识库名称

projectName

String

否

default

知识库所属项目,获取方式参见文档API 接入与技术支持
若不指定该字段,则在 default 项目下查询。
若需要操作指定项目下的知识库,需正确配置该字段。

resourceId

String

否

--

知识库唯一 ID
可通过创建知识库接口的返回值或知识库列表接口获取
可选择直接传 resourceId,或同时传 collectionName 和 projectName 作为知识库的唯一标识

docId

String

是

--

要查询的文档 ID
可通过文档上传结果或文档列表接口获取

returnTokenUsage

Boolean

否

false

是否返回文档向量化和文档生成摘要所消耗的 tokens

  • true:返回 token 用量信息;false:不返回 token 用量信息
响应消息
字段类型参数说明
collectionNameString知识库名称
docNameString文档名称
docHashString文档 hash
docIdString文档 id
addTypeString导入方式
docTypeString文档类型
descriptionString文档描述(当前仅支持图片文档)
createTimeLong文档创建时间
addedByString添加人
updateTimeLong文档更新时间
urlString原始文档链接
tosPathStringtos 路径
pointNumInteger切片数量
statusDocStatusDocStatus
titleString文档标题
sourceString知识来源(url,tos 等)
totalTokensObjecttoken 统计
docSummaryTokensInteger摘要 token 统计
docPremiumStatusDocPremiumStatusDocPremiumStatus
docSummaryString文档摘要
briefSummaryString简要摘要
docSizeInteger文档大小
metaStringmeta 信息
labelsMap<String, String>标签信息
videoOutlineMap<String, Object>视频大纲
audioOutlineMap<String, Object>音频大纲
statisticsMap<String, Object>统计信息
projectString项目名
resourceIdString知识库唯一 id

DocStatus

字段类型参数说明
processStatusInteger文档处理状态:0 成功、1 失败、2 排队中、3 更新中、5 删除中、6 处理中。
failedCodeInteger失败错误码
failedMsgString失败错误信息

DocPremiumStatus

字段类型参数说明
docSummaryStatusCodeInteger摘要状态码

failed_code 报错码:

failed_code错误描述处理建议
10001文档下载超时请上传重试。如果问题仍然存在,请联系我们
10003url 校验失败,请确认 url 链接请确认 url 链接正确后重试。如果问题仍然存在,请联系我们
10005飞书文档获取异常,请确认有效且授权请确认飞书文档权限问题,通过飞书开放平台 OpenAPI 飞书开放平台确认权限
30001超过知识库文件限制大小超过知识库配额限制。配额说明参考
35001超过知识库切片数量限制超过知识库配额限制。配额说明参考
35002FAQ 文档解析为空FAQ 文档解析结果为空,切片数为 0。请确保文档中包含有效数据
35004超过知识库 FAQ 文档 sheet 数量限制超过知识库配额限制。配额说明参考
36003结构化文档表头不匹配结构化文档表头不匹配,请确保上传文档中每个 sheet 的表头与预定义的知识库表结构完全一致
36004结构化文档数据类型转换失败结构化文档数据类型转换失败,请确保上传文档中每个 sheet 的单元格的内容格式与预定义的知识库表结构数据类型完全一致
36005超过知识库结构化文档 sheet 数量限制超过知识库配额限制。配额说明参考
36006超过知识库结构化文档有效行数限制超过知识库配额限制。配额说明参考
36007结构化文档解析为空结构化文档解析结果为空,切片数为 0。请确保文档中包含有效数据
36008embedding 的列组合长度超出限制缩短待 embedding 原始文本长度
其他错误码未知错误,请联系我们未知错误,请联系我们
状态码说明
状态码http状态码返回信息状态码说明
0200success成功
1000001401unauthorized鉴权失败
1000002403no permission权限不足
1000003400invalid request:%s非法参数
1000005400collection not existcollection 不存在
1001001400doc not existdoc 不存在
请求示例

首次使用知识库 SDK,可参考 使用说明
本示例演示了知识库 Java SDK 中 GetDoc 的基础使用方法,通过指定文档 ID 实现单篇文档查询,使用前需配置 API Key 鉴权参数(VIKING_API_KEY)。

package com.volcengine.vikingdb.runtime.knowledge.examples.doc_get;

import com.fasterxml.jackson.databind.ObjectWriter;
import com.volcengine.vikingdb.runtime.core.ApiClient;
import com.volcengine.vikingdb.runtime.core.RequestAddition;
import com.volcengine.vikingdb.runtime.core.auth.Auth;
import com.volcengine.vikingdb.runtime.core.auth.AuthWithApiKey;
import com.volcengine.vikingdb.runtime.enums.Scheme;
import com.volcengine.vikingdb.runtime.knowledge.model.CollectionMeta;
import com.volcengine.vikingdb.runtime.knowledge.model.response.DocInfo;
import com.volcengine.vikingdb.runtime.knowledge.service.KnowledgeCollectionClient;
import com.volcengine.vikingdb.runtime.knowledge.service.KnowledgeService;

public class Main {
    private static final ObjectWriter PRETTY_JSON = ApiClient.objectMapper.writerWithDefaultPrettyPrinter();
    private static final Scheme SCHEME = Scheme.HTTPS;
    private static final String HOST = "api-knowledgebase.mlp.cn-beijing.volces.com";
    private static final String REGION = "cn-beijing";
    private static final String PROJECT = "default";
    private static final String COLLECTION_NAME = "<YOUR_COLLECTION_NAME>";
    private static final String COLLECTION_RESOURCE_ID = "";
    private static final String DOC_ID = "<YOUR_DOC_ID>";

    public static void main(String[] args) throws Exception {
        String apiKey = getEnv("VIKING_API_KEY");
        if (apiKey.isEmpty()) {
            System.out.println("missing_auth: set VIKING_API_KEY");
            return;
        }
        Auth auth = new AuthWithApiKey(apiKey);

        KnowledgeService service = newKnowledgeService(auth);
        KnowledgeCollectionClient kc = service.collection(defaultCollectionMeta());

        DocInfo resp = kc.getDoc(DOC_ID, true, new RequestAddition());
        printJson("get_doc", resp);
    }

    private static KnowledgeService newKnowledgeService(Auth auth) {
        return new KnowledgeService(SCHEME, HOST, REGION, auth);
    }

    private static CollectionMeta defaultCollectionMeta() {
        return CollectionMeta.builder()
                .collectionName(COLLECTION_NAME)
                .projectName(PROJECT)
                .resourceId(COLLECTION_RESOURCE_ID)
                .build();
    }

    private static String getEnv(String name) {
        String v = System.getenv(name);
        if (v == null) {
            return "";
        }
        v = v.trim();
        return v.isEmpty() ? "" : v;
    }

    private static void printJson(String name, Object obj) throws Exception {
        if (obj == null) {
            System.out.println(name + ": null");
            return;
        }
        System.out.println(name + ": " + PRETTY_JSON.writeValueAsString(obj));
    }
}
最近更新时间:2026.09.15 21:40:36
这个页面对您有帮助吗?
有用
有用
无用
无用