C.W.K.
Stream
Lesson 03 of 05 · published

Where 절로 메타데이터 필터링

~20 min · chroma, filtering

Level 0Scout
0 XP0/41 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Chroma 가 지원하는 필터 operator

Chroma 의 where argument 는 작은 JSON DSL. 중요한 operator:

  • $eq, $ne — 같음/다름
  • $gt, $gte, $lt, $lte — 숫자/문자열 비교
  • $in, $nin — set 멤버십
  • $and, $or — 논리 결합

document 부분 문자열 검색

청크 텍스트 자체에 대한 full-text contains/regex 는 where_document 사용. 벡터 검색이 명백한 걸 놓칠 때의 escape hatch — where_document={'$contains': 'OAuth'} 로 fallback 하면 Chroma 안에서 기본 키워드 필터링 가능.

Code

벡터 검색 + 메타데이터 필터 결합·python
res = docs.query(
    query_embeddings=q_vec,
    n_results=5,
    where={
        '$and': [
            {'project':  {'$eq':  'cwkPippa'}},
            {'doc_type': {'$in':  ['markdown', 'code']}},
            {'updated_at': {'$gte': '2026-04-01'}},
        ],
    },
    where_document={'$contains': 'embedding'},
    include=['documents', 'metadatas', 'distances'],
)

External links

Exercise

한 프로젝트의 최근 7일 청크 중 'OAuth' 부분 문자열 포함, 본인 query 와의 시맨틱 유사도로 ranking 된 query 작성. 필터가 candidate count 를 절반으로 줄이고 ranking 도 여전히 OK 한 거 확인.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.