# Aurabase Vector Search & RAG Reference (pgvector) > Documentation: https://aurabase.cloud/en/docs/guides/rag-pgvector > Engine: PostgreSQL 18 with `vector` (`pgvector`) extension ## Technical Specifications - **Extension**: `vector` enabled on all Aurabase clusters. - **Standard Dimensions Supported**: - 1536: OpenAI `text-embedding-3-small`, `text-embedding-ada-002` - 3072: OpenAI `text-embedding-3-large` - 768: Google Gemini `text-embedding-004`, Mistral `mistral-embed` - **Distance Operators**: - `<=>`: Cosine Distance (recommended for semantic search) - `<->`: Euclidean Distance (L2) - `<#>`: Negative Inner Product ## Table & High-Performance HNSW Index ```sql create extension if not exists vector; create table documents ( id uuid primary key default gen_random_uuid(), content text not null, metadata jsonb default '{}'::jsonb, embedding vector(1536) not null ); -- HNSW index for sub-5ms p99 similarity search create index idx_documents_embedding on documents using hnsw (embedding vector_cosine_ops) with (m = 16, ef_construction = 64); ``` ## Cosine Similarity RPC Search Function ```sql create or replace function match_documents ( query_embedding vector(1536), match_threshold float, match_count int ) returns table (id uuid, content text, metadata jsonb, similarity float) language sql stable security invoker as $$ select id, content, metadata, 1 - (embedding <=> query_embedding) as similarity from documents where 1 - (embedding <=> query_embedding) > match_threshold order by embedding <=> query_embedding limit match_count; $$; ``` ## AI Gateway Integration (Sub-10ms Vector Pipelines) Instead of manually generating embeddings and querying raw SQL, the Aurabase AI Gateway automates the entire vector lifecycle: ```typescript // 1. Automatic Ingestion & Chunking into pgvector await aura.ai.ragIngest({ document: 'Enterprise knowledge base document text...', namespace: 'kb', chunk_size: 1000, chunk_overlap: 200, }) // 2. High-Performance Semantic Search const { data: results } = await aura.ai.semanticSearch( 'What is our refund policy?', 'kb', { threshold: 0.82, top_k: 5 } ) // 3. One-Call Grounded RAG Synthesis const { data: rag } = await aura.ai.rag({ question: 'What is our refund policy?', namespace: 'kb', }) console.log(rag?.answer, rag?.sources) ```