Logo
OFFLINEPIXEL
Elasticsearch (Keyword/TF-IDF) → FAISS + Sentence Transformers

Elasticsearch to FAISS Vector Search Migration

A guide to migrating keyword-based Elasticsearch to FAISS vector search for semantic similarity at 100x lower latency.

Elasticsearch (Keyword/TF-IDF) → FAISS + Sentence Transformers Incremental MEDIUM Difficulty

Elasticsearch to FAISS Vector Search Migration

A guide to migrating keyword-based Elasticsearch to FAISS vector search for semantic similarity at 100x lower latency.

Estimated Timeline3-5 months
Primary Rolefaiss-expert

Executive Summary

An e-commerce search platform using Elasticsearch keyword matching had 65% recall—users couldn't find products using natural language. Over 4 months, they migrated to FAISS vector search with sentence embeddings, achieving 92% recall and 10x faster queries. This guide covers embedding generation, index building, and hybrid search strategies.

Replace keyword search with semantic embeddings for natural language
FAISS provides 100x faster similarity search than Elasticsearch script_score
Hybrid search (keyword + vector) improves recall 15%
Embedding quality determines search relevance

Why Migrate from Elasticsearch Keyword Search

Elasticsearch's keyword-based search failed for synonyms and natural language queries. Users searched "comfortable running shoes" and got no results for "soft sneakers."

  • 65% recall (users can't find products)
  • 30% search abandonment rate
  • Elasticsearch cluster cost $10k/month (100 nodes)
  • Manual synonym lists (2 engineers full-time)

FAISS Migration Readiness

The team spent 1 month generating embeddings (Sentence-BERT), setting up FAISS, and creating evaluation framework.

  • Sentence-BERT model (fine-tuned on product descriptions)
  • FAISS index (IVF, HNSW selection)
  • Embedding pipeline (100M products → 100GB vectors)
  • Evaluation dataset (10K queries with relevance labels)
  • Hybrid search (Elasticsearch + FAISS) for gradual rollout

Elasticsearch Assessment

Elasticsearch had 100M documents, 100 nodes, 10k queries/second. Keyword search worked for exact matches but failed for synonyms.

Technical Debt

  • • Manual synonym list (10K terms, outdated)
  • • No semantic understanding (misses 35% of relevant results)
  • • script_score vector search too slow (500ms)
  • • High operational cost (100 nodes)

Risks

  • • Embedding quality (does it capture domain semantics?)
  • • FAISS index building time (100M vectors → 1 week)
  • • Hybrid search complexity
  • • Team learning curve (FAISS vs Elasticsearch)

Target FAISS Vector Search Architecture

FAISS for vector search + Elasticsearch for keyword (hybrid reranking).

Sentence-BERT (fine-tuned on product data)FAISS index (IVF4096, PQ64, 100M vectors)Elasticsearch (reduced to 10 nodes for keyword)Hybrid reranker (combine vector + keyword scores)GPU inference for embeddings (8x A100)

4-Month FAISS Migration

  1. Step 1: Phase 1: Embedding (Month 1)

    Generated embeddings for 100M products using Sentence-BERT (2 weeks on GPU).

  2. Step 2: Phase 2: FAISS Index (Month 2)

    Built IVF4096 index, recall 92% at 10ms latency.

  3. Step 3: Phase 3: Hybrid (Month 3)

    Hybrid search (vector + keyword) shadow mode, compare to Elasticsearch.

  4. Step 4: Phase 4: Cutover (Month 4)

    100% traffic on hybrid search, Elasticsearch reduced to 10 nodes.

Product Data to Embeddings

Product titles, descriptions, and attributes converted to 384-dim embeddings via Sentence-BERT.

  • Batch inference (10M products/day)
  • Embedding storage (100M × 384 × 4 bytes = 150GB)
  • Quantization (FP16 reduces to 75GB, minimal recall loss)
  • Incremental updates (new products embedded daily)

Common Elasticsearch to FAISS Mistakes

Using generic embeddings (not fine-tuned)

Impact: Recall 70% vs fine-tuned 92%

Prevention: Fine-tune Sentence-BERT on domain data

No hybrid search (pure vector)

Impact: Misses exact term matches (product codes)

Prevention: Hybrid vector + keyword search

Single-stage retrieval only

Impact: HNSW recall 85%, reranking improves to 95%

Prevention: Two-stage: FAISS + cross-encoder reranker

Not quantizing embeddings

Impact: Index size 150GB (expensive)

Prevention: FP16 quantization (75GB, 1% recall loss)

Migration Success Metrics

Recall@10: 65% → 92% (42% improvement)
Query latency: 500ms → 15ms (97% reduction)
Search abandonment: 30% → 12% (60% reduction)
Elasticsearch nodes: 100 → 10 (90% reduction)

Who Should Lead FAISS Migration

Recommended Roles

FAISS Expert (3+ years)Search Engineer (Elasticsearch)ML Engineer (embeddings)

Required Experience

  • FAISS index optimization
  • Sentence-BERT fine-tuning
  • Elasticsearch production
  • Hybrid search design

Related Roles

Frequently Asked Questions

Do we still need Elasticsearch after FAISS migration?
Yes—for exact term matches (product codes) and filtering. Hybrid search gives best results.
What embedding model works best?
Sentence-BERT fine-tuned on domain data. For e-commerce, MS MARCO or fine-tuned BERT.
How often to rebuild FAISS index?
Full rebuild weekly; incremental updates daily for new products.