디렉토리 생성 - PowerShell
mkdir C:\qdrant
cd C:\qdrant
mkdir storage,snapshots
docker-compose.yml 생성
services:
qdrant:
image: qdrant/qdrant:latest
container_name: qdrant
restart: unless-stopped
# 로컬에서만 접근(개발용). 외부 공개 원치 않으면 localhost 바인딩 유지.
ports:
- "127.0.0.1:6333:6333" # REST
- "127.0.0.1:6334:6334" # gRPC(안 쓰면 삭제 가능)
volumes:
- ./storage:/qdrant/storage
- ./snapshots:/qdrant/snapshots
컬렉션 생성 - PowerShell
# 실행
docker compose up -d
docker ps
# 실행 확인
Invoke-RestMethod http://127.0.0.1:6333/
# 컬렉션 생성 요청 만들기
$body = @{
vectors = @{
size = 1536
distance = "Cosine"
}
} | ConvertTo-Json -Depth 10
# 생성 호출
Invoke-RestMethod -Method Put `
-Uri "http://127.0.0.1:6333/collections/items" `
-ContentType "application/json" `
-Body $body
기타 명령어 - PowerShell
# 컬렉션 목록 보기
curl http://127.0.0.1:6333/collections
# 특정 컬렉션 상세 보기
Invoke-RestMethod "http://127.0.0.1:6333/collections/items" | ConvertTo-Json -Depth 30
# 실수했을 때: 컬렉션 삭제 후 재생성
Invoke-RestMethod -Method Delete -Uri "http://127.0.0.1:6333/collections/items"
payload 인덱스 만들기 - PowerShell
# item_type_code_nm: keyword 인덱스
$idx1 = @{
field_name = "itemTypeCodeNm"
field_schema = "keyword"
} | ConvertTo-Json -Depth 10
Invoke-RestMethod -Method Put `
-Uri "http://127.0.0.1:6333/collections/items/index" `
-ContentType "application/json" `
-Body $idx1
# item_dtl_type_code_nm: keyword 인덱스
$idx2 = @{
field_name = "itemDtlTypeCodeNm"
field_schema = "keyword"
} | ConvertTo-Json -Depth 10
Invoke-RestMethod -Method Put `
-Uri "http://127.0.0.1:6333/collections/items/index" `
-ContentType "application/json" `
-Body $idx2
# 인덱스 확인
Invoke-RestMethod "http://127.0.0.1:6333/collections/items" |
Select-Object -ExpandProperty result |
Select-Object payload_schema |
ConvertTo-Json -Depth 20
테스트 - PowerShell
# 1536 길이 랜덤 벡터 만들기
$VECTOR_SIZE = 1536
$vec = @()
1..$VECTOR_SIZE | ForEach-Object { $vec += [single]((Get-Random -Minimum -1000000 -Maximum 1000000) / 1000000.0) }
# upsert (payload에 category/코드/text 넣기)
$upsert = @{
points = @(
@{
id = 1001
vector = $vec
payload = @{
item_id = 1001
item_type_code_nm = "화장품"
item_dtl_type_code_nm = "세럼"
text = "OO 미백 세럼 / skincare / 미백 기능 성분 함유로 피부톤 개선"
}
}
)
} | ConvertTo-Json -Depth 50
Invoke-RestMethod -Method Put `
-Uri "http://127.0.0.1:6333/collections/items/points?wait=true" `
-ContentType "application/json" `
-Body $upsert
# 검색 (topK=1, payload 포함)
$search = @{
vector = $vec
limit = 1
with_payload = $true
} | ConvertTo-Json -Depth 20
$r = Invoke-RestMethod -Method Post `
-Uri "http://127.0.0.1:6333/collections/items/points/search" `
-ContentType "application/json" `
-Body $search
$r.result | Format-Table id, score
# 필터 검색 (category=skincare)
$search2 = @{
vector = $vec
limit = 5
with_payload = $true
filter = @{
must = @(
@{ key="itemSeq"; match=@{ value=38 } }
)
}
} | ConvertTo-Json -Depth 30
Invoke-RestMethod -Method Post `
-Uri "http://127.0.0.1:6333/collections/items/points/search" `
-ContentType "application/json" `
-Body $search2
기타명령어 - PowerShell
# 포인트 한 개만 지우기
Invoke-RestMethod -Method Post `
-Uri "http://127.0.0.1:6333/collections/items/points/delete?wait=true" `
-ContentType "application/json" `
-Body (@{ points = @(1) } | ConvertTo-Json)
# 전체 적재(처음 1회)
Invoke-RestMethod -Method Post "http://localhost:8080/debug/batch/full"
# 증분 적재(이후에는 이걸 반복)
Invoke-RestMethod -Method Post "http://localhost:8080/debug/batch/incremental"
# 데이터 하나만 조회하기
$collection = "items"
$itemSeq = 1
$body = @{
ids = @($itemSeq)
with_payload = $true
with_vector = $true
} | ConvertTo-Json -Depth 10
$result = Invoke-RestMethod `
-Method Post `
-Uri "http://localhost:6333/collections/$collection/points" `
-ContentType "application/json" `
-Body $body
# payload, vector 조회하기
$result.result[0].payload | ConvertTo-Json -Depth 10
$result.result[0].vector | ConvertTo-Json -Depth 10