Filtreli Aramayı En İyi Duruma Getirme
Kısmi ve bileşik dizinleme stratejilerini kullanarak vektör benzerliğini üstveri filtreleriyle birleştiren pgvector sorgularını en iyi duruma getirin.
Filtreli Aramayı En İyi Duruma Getirme, CoddyKit'te ücretsiz bir Vector Databases: Pinecone, Weaviate & pgvector dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Vector Databases: Pinecone, Weaviate & pgvector öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Vector Databases: Pinecone, Weaviate & pgvector kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
The Filtered Search Problem
Real queries often combine a vector search with a metadata WHERE filter. Naive combinations can defeat the vector index and become slow.
SELECT id FROM docs
WHERE category = 'news'
ORDER BY embedding <=> '[...]'::vector
LIMIT 10;Why Filters Hurt Recall
ANN indexes return approximate nearest neighbors before the filter applies. If most candidates are filtered out, you may get fewer than LIMIT results — this is over-filtering.
Increasing Search Scope
Raise hnsw.ef_search (or IVFFlat probes) so the index scans more candidates before filtering, improving recall on selective filters.
SET hnsw.ef_search = 100;Partial Indexes
For a common, low-cardinality filter value, build a partial index covering only those rows. The index then perfectly matches the filtered subset.
CREATE INDEX ON docs
USING hnsw (embedding vector_cosine_ops)
WHERE category = 'news';When Partial Indexes Win
Partial indexes shine when:
- Filter values are few and known
- Each subset is large enough to matter
- Queries almost always include that filter
B-tree Support Indexes
For high-cardinality filters, add a regular B-tree index on the metadata column. The planner can combine it with the vector scan.
CREATE INDEX ON docs (category);
CREATE INDEX ON docs (published_at);Iterative Index Scans
Newer pgvector supports iterative scans, which keep fetching from the index until enough rows pass the filter. Enable it to avoid under-filling results.
SET hnsw.iterative_scan = 'relaxed_order';Pre-filtering vs Post-filtering
Pre-filter: narrow rows first, then vector search (good for very selective filters). Post-filter: vector search first, then filter (good for broad filters). Test both.
Measuring with EXPLAIN
Always confirm the plan. Look for Index Scan using ... hnsw rather than a sequential scan.
EXPLAIN ANALYZE
SELECT id FROM docs
WHERE category = 'news'
ORDER BY embedding <=> '[...]'::vector
LIMIT 10;Combining Strategies
A robust setup often uses partial indexes for hot filters, B-tree indexes for the rest, and a tuned ef_search with iterative scans as a safety net.
Checklist
Before shipping a filtered vector query:
- Verify index usage with EXPLAIN
- Confirm you reliably get LIMIT results
- Benchmark latency at p95
Quick Check
Test filtered search knowledge.
Recap
You learned why filters challenge ANN indexes and how partial indexes, B-tree support indexes, ef_search tuning, and iterative scans keep filtered vector queries both fast and accurate.
Sıkça Sorulan Sorular
“Filtreli Aramayı En İyi Duruma Getirme” dersi ücretsiz mi?
Evet — “Filtreli Aramayı En İyi Duruma Getirme” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Vector Databases: Pinecone, Weaviate & pgvector kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Vector Databases: Pinecone, Weaviate & pgvector kursu toplamda 4 dersten oluşur.
“Filtreli Aramayı En İyi Duruma Getirme” dersinde ne öğreneceğim?
Kısmi ve bileşik dizinleme stratejilerini kullanarak vektör benzerliğini üstveri filtreleriyle birleştiren pgvector sorgularını en iyi duruma getirin. Vector Databases: Pinecone, Weaviate & pgvector ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Vector Databases: Pinecone, Weaviate & pgvector öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Vector Databases: Pinecone, Weaviate & pgvector, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Filtreli Aramayı En İyi Duruma Getirme” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Vector Databases: Pinecone, Weaviate & pgvector dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Vector Databases: Pinecone, Weaviate & pgvector dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Hız İçin IVFFlat Dizinleme
- Geri Getirme Oranı İçin HNSW Dizinleme
- Sorgu Performansını Ayarlama
- Filtreli Aramayı En İyi Duruma Getirme