TDTech Digest

212. 지식 기반에 문서 직접 수집 (Ingest documents directly into a knowledge base)

  • 원문: English
  • 위치: Additional capabilities › Knowledge Bases › Build a knowledge base with vector stores › Ingest changes directly into a knowledge base › Ingest documents directly into a knowledge base

한 줄 요약

IngestKnowledgeBaseDocuments로 문서(+메타데이터)를 지식 기반에 바로 넣습니다. Custom 데이터 소스는 인라인 또는 S3, S3 데이터 소스는 S3 위치만 지정할 수 있습니다. 한 번에 콘솔 10개 / API 25개까지입니다.

쉽게 말하면

문서 ID를 정해 내용을 보내면 바로 검색 가능한 상태가 됩니다. 같은 ID(또는 S3 위치)로 다시 보내면 덮어쓰기(업데이트) 입니다.

핵심 내용

데이터 소스별 지원 방식

데이터 소스인라인 문서S3 위치 문서메타데이터
Amazon S3❌✅S3(.metadata.json)만
Custom✅✅인라인 또는 S3
  • 한도: 콘솔 10개, API 25개 문서/요청 (Bedrock 서비스 할당량)
  • ⚠️ 같은 문서 식별자나 S3 위치가 이미 있으면 덮어씁니다.
  • ⚠️ 콘텐츠를 인라인으로 정의했다면 메타데이터도 인라인이어야 합니다.

콘솔

Knowledge bases → 지식 기반 → Data source → Documents → Add documents

  • Add documents directly: 문서 식별자 입력 → Upload 또는 Add document inline(형식 선택 후 텍스트 입력) → (선택) 메타데이터(key/type/value)
  • Add S3 documents: 문서 식별자 → S3 URI(현재 계정 또는 다른 계정) → (선택) 메타데이터 소스(S3 URI 또는 직접 입력)

API 요청 구조

PUT /knowledgebases/{kbId}/datasources/{dsId}/documents, 본문은 documents 배열(KnowledgeBaseDocument: content + 선택 metadata).

콘텐츠 형태content 핵심 필드
Custom · 인라인 텍스트dataSourceType: CUSTOM, custom.sourceType: IN_LINE, custom.customDocumentIdentifier.id, custom.inlineContent.type: TEXT, textContent.data
Custom · 인라인 바이트위와 같되 inlineContent.type: BYTE, byteContent.data(Base64), byteContent.mimeType (예: application/pdf)
Custom · S3custom.sourceType: S3, S3 위치(uri, bucketOwnerAccountId)
S3 데이터 소스dataSourceType: S3, s3.s3Location.uri
메타데이터 형태metadata 구조
인라인type: IN_LINE_ATTRIBUTE, inlineAttributes[] = {key, value:{type: STRING|BOOLEAN|NUMBER|STRING_LIST, stringValue/booleanValue/numberValue/stringListValue}}
S3type: S3_LOCATION, s3Location{uri, bucketOwnerAccountId} → 파일 형식은 201
{ "documents": [{
  "content": { "dataSourceType": "CUSTOM", "custom": {
    "customDocumentIdentifier": { "id": "MyDocument" },
    "inlineContent": { "type": "TEXT", "textContent": { "data": "Hello world!" } },
    "sourceType": "IN_LINE" } },
  "metadata": { "type": "IN_LINE_ATTRIBUTE", "inlineAttributes": [
    { "key": "year", "value": { "type": "NUMBER", "numberValue": 1988 } } ] }
}]}
  • 메타데이터 활용(검색 필터) → 241
  • ⚠️ S3 데이터 소스에 직접 수집한 문서는 S3 버킷에 추가되지 않습니다. S3에도 넣어 두지 않으면 다음 Sync 때 제거/덮어쓰기될 수 있습니다.

📝 원문 확인 필요: (1) Custom·S3 문서 형식이 스키마 설명에서는 custom.s3Location, 예시에서는 custom.s3.s3Location으로 서로 다릅니다. (2) S3 데이터 소스 설명은 bucketOwnerAccountId를 넣으라고 하지만 스키마 예시에는 그 필드가 없고, 마지막 예시는 bucketOwnerId라는 다른 이름을 씁니다. (3) 예시의 uri가 객체 경로가 아닌 버킷 이름(amzn-s3-demo-bucket)만 적혀 있습니다. 실제 구현 시 API Reference(DocumentContent, S3Location)를 확인하세요.

SA 관점

  • 25개/요청 제한이 있으므로 대량 적재는 Sync로, 변경분 실시간 반영은 직접 수집으로 나누는 것이 현실적입니다.
  • 문서 ID 체계를 원본 시스템의 키(예: 티켓 ID)와 1:1로 맞추면 업데이트·삭제가 단순해집니다.
  • 바이너리 문서는 Base64 인라인보다 S3 경유가 요청 크기·재시도 측면에서 다루기 쉽습니다(Custom 데이터 소스 기준).