Store 검색 — 시맨틱 쿼리와 필터
Store 검색 — 시맨틱 쿼리와 필터
Store 검색은 키워드가 아니라 의미를 이해해요. 그래서 대화형 검색이나 복잡한 질문에 특히 유용해요. 기본 검색부터 필터, 쿼리 재작성, 멀티 Store 검색까지 살펴볼게요.
기본 검색은 이렇게 해요.
from mixedbread import Mixedbread
mxbai = Mixedbread(api_key="YOUR_API_KEY")
response = mxbai.stores.search(
query="How does authentication work?",
store_identifiers=["my-knowledge-base"],
top_k=5,
)
for chunk in response.data:
print(chunk)
REST API로는 POST https://api.mixedbread.com/v1/stores/search를 호출해요.
curl -X POST https://api.mixedbread.com/v1/stores/search \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
"query": "How does authentication work?",
"store_identifiers": ["my-knowledge-base"],
"top_k": 5
}'
결과는 관련성에 따라 자동으로 순위가 매겨지고 신뢰도 점수가 함께 나와요.
시작할 때는 대부분 top_k=10이면 충분해요. 포괄적인 검색이 필요하면 키우고, 응답이 빨라야 하면 줄이면 돼요.
Filter — 메타데이터 기반으로 결과를 좁힐 수 있어요. all 안에 연산자 목록을 넣어 여러 조건을 동시에 적용해요.
results = mxbai.stores.search(
query="user authentication",
store_identifiers=["docs"],
filters={
"all": [
{"key": "category", "operator": "eq", "value": "documentation"},
{"key": "difficulty", "operator": "in", "value": ["beginner", "intermediate"]}
]
}
)
Rewrite Query — 전용 AI 모델이 쿼리를 재작성해 더 나은 시맨틱 검색을 만들어요. 키워드 대신 의미적 자격을 채우고 컨텍스트를 보강하죠. search_options: {"rewrite_query": True}로 켜요. 재작성된 쿼리는 /v1/stores/{store_identifier}/events 엔드포인트에서 확인할 수 있어요. 추가 에이전트 호출로 지연이 늘어나니, 모든 쿼리에 쓸 필요는 없어요.
Multi Store Search — 여러 Store를 동시에 검색할 수 있어요.
results = mxbai.stores.search(
query="machine learning deployment",
store_identifiers=["documentation", "research-papers", "tutorials", "code-examples"],
top_k=15
)
더 알아보기
- https://www.mixedbread.com/docs/stores/search — Store 검색
- https://www.mixedbread.com/docs/quickstart — Stores 퀵스타트