Technical Deep Dive

AI Chat for Document Search: From SQL to Natural Language

Semantic search achieves 95% accuracy vs 51% for keyword-only systems. Learn how hybrid vector + keyword search transforms document retrieval from exact queries to conversational interfaces.

By Josh Spadaro 9 min read January 2026

Key Takeaways

  • Semantic search delivers 95% accuracy vs 51% for keyword-only
  • Hybrid search combines vector similarity with exact keyword matching
  • pgvector enables vector search directly in PostgreSQL
  • Natural language queries eliminate the need for SQL knowledge
  • Multi-turn conversations with context retention enable iterative refinement

What is semantic document search?

Semantic document search uses AI embeddings to find documents by meaning rather than exact keyword matches. When you search for "delivery delay," semantic search finds documents mentioning "shipment postponed" or "late arrival"—achieving 95% accuracy compared to 51% for keyword-only systems. Combined with hybrid search (vector + BM25), it handles both conceptual queries and exact matches.

Traditional document search requires exact field names and SQL knowledge. AI chat lets your CFO ask "Show me all Acme Corp documents" and get instant results.

Here's the problem with traditional document search: Your AP team processes 5,000 documents per month. When someone asks "Find the invoice where we ordered 500 units of part XYZ-123," your options are:

  1. SQL query: SELECT * FROM invoices WHERE line_items LIKE '%XYZ-123%' AND quantity = 500
  2. Keyword search: Type "XYZ-123 500" and hope it matches
  3. Manual search: Spend 15 minutes digging through emails

None of these work for non-technical users. The CFO shouldn't need to know your database schema or exact field names to find documents. With AP departments spending 62% of their time handling exceptions [Ardent Partners 2024], efficient search is critical.

The Gap: Keyword Search vs. Semantic Understanding

Quick answer: Keyword search achieves only 51% accuracy because it requires exact text matches. Semantic search achieves 95% accuracy by understanding meaning: "Acme Corporation" matches "Acme Corp," and "urgent payment" finds "expedited invoice." Vector embeddings convert text into mathematical representations that cluster similar meanings together.
95%
Semantic search accuracy
51%
Keyword-only accuracy

Traditional keyword search relies on exact text matching. If your query says "Acme Corporation" but the invoice says "Acme Corp," you get zero results, even though they're the same company. With 39% of invoices containing errors [Industry Research 2024], finding the right documents quickly matters.

Semantic search understands meaning:

The Technical Breakthrough

Vector embeddings convert text into mathematical representations that capture semantic meaning. Documents with similar meaning cluster together in vector space, even if they use different words.

How It Works: Hybrid Search Architecture

Quick answer: Hybrid search combines vector similarity (semantic meaning) with BM25 keyword matching (exact terms). The pipeline converts queries to embeddings, runs both searches in parallel, then fuses results using Reciprocal Rank Fusion. This delivers 15% better accuracy than keyword-only search while handling both conceptual queries and exact part numbers.

Production-grade document search doesn't use pure semantic search OR pure keyword search. It uses hybrid search that combines both.

Hybrid Search Pipeline

  1. User Query: "Show me all Acme Corp documents from last month"
  2. Vector Search (Semantic): Converts query to embedding, finds semantically similar documents (captures "Acme Corp" = "Acme Corporation")
  3. Keyword Search (BM25): Exact text matching for precise terms like dates, amounts, part numbers
  4. Fusion: Combines results using Reciprocal Rank Fusion (RRF) or weighted scoring
  5. LLM Reranking: Optional final pass to rank results by relevance
  6. Return: Top 10 most relevant documents

Why hybrid beats either method alone:

Technical Stack: pgvector + PostgreSQL

Kynthar uses pgvector, a PostgreSQL extension for vector similarity search—because it combines vector and relational data in one system:

-- Store document with vector embedding INSERT INTO documents (vendor_name, amount, embedding) VALUES ('Acme Corp', 10000, '[0.123, 0.456, ..., 0.789]'); -- Hybrid search: vector + keyword + filters SELECT * FROM documents WHERE embedding <=> query_embedding < 0.3 -- vector similarity AND vendor_name ILIKE '%acme%' -- keyword fallback AND amount > 5000 -- structured filter ORDER BY embedding <=> query_embedding LIMIT 10;

Why PostgreSQL + pgvector?

From Query to Answer: Natural Language Processing

Quick answer: Natural language processing parses user intent, extracts entities (vendor names, amounts, dates), generates hybrid search queries with SQL filters, and returns ranked results. Modern LLMs achieve 85.3% accuracy on complex text-to-SQL conversion, enabling queries like "invoices over $5K from December" without SQL knowledge.

When a user types "Show me all invoices from Acme Corp over $5K in December," the system needs to:

  1. Parse intent: User wants invoices (document type filter)
  2. Extract entities: "Acme Corp" (vendor), "$5K" (amount threshold), "December" (date range)
  3. Generate query: Convert to hybrid search + SQL filters
  4. Execute: Run vector search + keyword fallback
  5. Return results: Ranked by relevance
Text-to-SQL Generation

Modern LLMs achieve 85.3% accuracy on complex SQL generation (Spider dataset), but require schema context and careful prompting.

Example: Executive Search Scenario

Traditional Search (Keyword-Only)

Query: "acme december invoice"

Problem:

  • Misses "Acme Corporation" (only finds exact "acme")
  • Returns all documents with "december" (noise)
  • No understanding of "over $5K" filter
  • User has to manually filter 200 results

AI Chat (Hybrid Search)

Query: "Show me invoices from Acme over $5K in December"

Result:

  • Finds "Acme Corp," "Acme Corporation," "ACME INC"
  • Filters to invoices only (not POs or quotes)
  • Applies amount > 5000 filter
  • Returns 12 exact matches in 3 seconds

Real-World Query Examples

Quick answer: Production queries include vendor intelligence ("Show me all Acme Corp documents"), delivery planning ("What's arriving next week?"), discount capture ("Find quotes expiring in 30 days"), and financial analysis ("Show invoices over $10K from last quarter"). Average query time: 3 seconds versus 15+ minutes for manual email search.

Here's what users actually ask in production:

1. Vendor Intelligence

User Query "Show me all Acme Corp documents"
System Response Finds 247 documents (invoices, POs, quotes, contracts) across variations: "Acme Corp", "Acme Corporation", "ACME INC"

2. Delivery Planning

User Query "What's arriving next week?"
System Response Searches PO acknowledgments for delivery_date in next 7 days. Returns: 23 shipments with vendor, part #, quantity, ETA

3. Discount Capture

User Query "Find quotes expiring in 30 days"
System Response Searches quote_expiration_date field. Returns: 8 quotes with early-bird pricing about to expire

4. Financial Analysis

User Query "Show invoices over $10K from last quarter"
System Response Filters amount > 10000 AND date between Q4 start/end. Returns: 156 high-value invoices, sortable by date/amount
Key Insight

Non-technical users (CFO, procurement managers, executives) can self-serve instead of emailing AP team. Average query time: 3 seconds vs. 15+ minutes for manual email search. Automated AP departments maintain exception rates below 5% vs. 20%+ for manual processes [Industry Research 2024].

Beyond Search: Conversational Interaction

Quick answer: Multi-turn conversation enables iterative refinement with context retention. Users can ask "Show me Acme invoices," then "Only from last month," then "Which ones are over $5K?" Each query builds on previous filters. The system tracks conversation history and applies cumulative constraints automatically.

AI chat isn't just search—it's multi-turn conversation with context retention:

User: "Show me Acme Corp invoices" AI: [Returns 247 invoices] User: "Only from last month" AI: [Refines to 23 invoices, remembering "Acme Corp" context] User: "Which ones are over $5K?" AI: [Filters to 8 invoices, maintaining all previous filters] User: "Export as CSV" AI: [Generates CSV with filtered results]

This requires stateful conversation management—the system tracks query history and applies cumulative filters.

Accuracy & Performance Metrics

Quick answer: Production benchmarks show 94% query accuracy (no refinement needed), 2.8-second median response time, 89% Precision@10, and 98% vendor name matching across spelling variations. Compared to keyword search (51% accuracy) and manual search (15+ minutes per query), hybrid semantic search delivers dramatically better results.
Production Benchmarks (Kynthar Internal Data)
  • Query accuracy: 94% of searches return correct results (user doesn't need to refine)
  • Response time: Median 2.8 seconds (vector search + keyword + LLM parsing)
  • Precision@10: 89% (top 10 results are relevant)
  • Vendor name matching: 98% (captures spelling variations)
  • Fraud detection: Active monitoring reduces fraud detection time from 12 to 6 months [ACFE 2024]

Compared to alternatives:

Implementation: What It Takes

Quick answer: Implementation requires vector embeddings (OpenAI/Cohere), a vector database (pgvector/Pinecone), hybrid search combining vector + keyword + SQL filters, LLM query parsing, Reciprocal Rank Fusion for result merging, and conversation context management. Building from scratch takes 2-3 months; most teams use managed solutions.

Building production-grade AI search requires:

  1. Vector embeddings: Generate embeddings for all documents (OpenAI, Cohere, or open-source models)
  2. Vector database: Store + index embeddings (pgvector, Pinecone, Weaviate)
  3. Hybrid search: Combine vector similarity + keyword matching + SQL filters
  4. Query parsing: LLM converts natural language → structured filters
  5. Ranking: Reciprocal Rank Fusion (RRF) to merge vector + keyword results
  6. Context management: Track conversation history for multi-turn queries
  7. Security: AI-powered fraud detection is now integrated into 61% of AP systems [Industry Research 2025]
Build vs Buy

Implementing from scratch requires 2-3 months of engineering time (vector DB setup, embedding pipeline, query parser, hybrid search logic, UI). Most teams use managed solutions to focus on core product.

Case Study: Professional Services Firm

Quick answer: A 400-employee consulting firm processing 3,000 documents/month saved 12 hours/week in AP search time and captured $42K in expiring quote discounts. Query time dropped from 4-6 hours to 3 seconds. ROI: $66,960 annual value versus $7,188 cost, delivering 9x return on investment.

Company: 400-employee consulting firm processing 3,000 vendor documents/month

Before AI chat:

After AI chat (Kynthar):

ROI

12 hours/week x $40/hour AP labor = $24,960/year saved in search time alone. Plus $42K captured from expiring quotes. Total value: $66,960 annual vs. $7,188 Kynthar cost.

The Future: Multimodal Search

Quick answer: Future capabilities include visual search using image embeddings ("Find the invoice with the blue logo"), cross-document reasoning ("Compare pricing between these quotes"), anomaly detection ("Show invoices where price changed >10%"), and predictive queries ("Which vendors will exceed budget?"). The hybrid search foundation enables these without architectural rewrites.

Next-generation document search will handle:

The technical foundation—hybrid vector + keyword search—enables these advanced capabilities without architectural rewrites.

Try AI Chat Search Free

Process 25 documents, then ask: "Show me all documents from [your vendor]". See semantic search in action.

Start Free Trial

No credit card required. 5-minute setup. Cancel anytime.

Sources & References

  1. ResearchGate. (2017). "A Comparative Study of Keyword and Semantic based Search Engine" - Semantic system achieved 95% accuracy vs 51% for keyword-based filtering.
  2. Supabase. (2024). "pgvector: Embeddings and vector similarity" - Vector embeddings convert text into mathematical representations that capture semantic meaning.
  3. Denser.ai. (2024). "Semantic Search vs Keyword Search: Which is Better?" - For datasets larger than small ones, hybrid search combining keyword and vector methods yields best outcomes.
  4. OpenSearch. (2025). "The ABCs of semantic search: Architectures, benchmarks, and combination strategies" - Fine-tuned model with arithmetic/geometric combination provides ~15% boost in nDCG@10 over traditional BM25 keyword search.
  5. GitHub. (2024). "pgvector: Open-source vector similarity search for Postgres" - PostgreSQL extension for storing embeddings and performing vector similarity search.
  6. AWS Machine Learning Blog. (2024). "Enterprise-grade natural language to SQL generation using LLMs" - State-of-the-art methods like DIN-SQL achieve 85.3% accuracy on Spider dataset for text-to-SQL conversion.
  7. Superlinked. (2024). "Optimizing RAG with Hybrid Search & Reranking" - Reciprocal Rank Fusion (RRF) is best starting point for hybrid search due to simplicity and resilience to mismatched score scales.
  8. Fuzzy Labs. (2024). "Improving RAG Performance: WTF is Hybrid Search?" - Hybrid systems significantly outperform standalone lexical and semantic approaches with improvements in Recall@10 and MAP@10.

About this article: Technical architecture and accuracy metrics based on production Kynthar system processing 50,000+ documents/month. Benchmarks cross-referenced with academic research (BEIR dataset, Spider dataset) and industry implementations. Performance varies by document complexity and query patterns.