Prompt

How do I migrate from Elasticsearch to vector search?

Technology / Databases1 observationLast seen Oct 7, 2026

Latest observation

Oct 7, 2026OpenAI APIWeb search: off

Migrating from Elasticsearch to vector search usually means moving from keyword/full-text retrieval to semantic retrieval using embeddings. In practice, many teams keep Elasticsearch for lexical search and add a vector database or vector index for semantic search, then blend the two.

Here’s a practical migration path.


1) Decide what “vector search” is replacing

First, identify your use case:

  • Semantic document search: “Find docs about payment failures” even if those exact words aren’t present.
  • Similarity search: “Find items like this product / ticket / paragraph.”
  • RAG retrieval: fetch relevant chunks for an LLM.
  • Hybrid search: combine keyword + semantic ranking.

If your current Elasticsearch setup depends on:

  • exact term matching,
  • filters/facets,
  • boolean queries,
  • aggregations,

then vector search is usually not a full replacement. It’s often an additional retrieval layer.


2) Choose a target architecture

Common options:

Option A: Elasticsearch with vector support

If you already use Elasticsearch, the easiest path may be to use:

  • dense_vector
  • kNN / approximate nearest neighbor search
  • hybrid scoring with BM25 + vector similarity

This minimizes operational change.

Option B: Dedicated vector database

Examples:

  • Pinecone
  • Weaviate
  • Milvus
  • Qdrant
  • pgvector (Postgres)
  • OpenSearch vector search

Best if semantic retrieval is central and you want specialized indexing/query behavior.

Option C: Hybrid architecture

  • Elasticsearch for keyword search, filters, aggregations
  • Vector DB for semantic similarity
  • Merge/rerank results in your app

Best for production search experiences.


3) Define your embedding strategy

Vector search requires converting text into embeddings.

Questions to answer:

  • What model will generate embeddings?
    • OpenAI, Cohere, Voyage, Sentence Transformers, etc.
  • What unit do you embed?
    • whole documents
    • paragraphs
    • chunks of 200–500 tokens
  • What dimension size?
    • depends on the model
  • Do you need multilingual embeddings?

Important:

For long documents, chunking is usually necessary. Search works better on semantically coherent chunks than on entire large docs.


4) Restructure your data model

Elasticsearch documents often contain:

  • full text
  • metadata
  • nested fields
  • analyzers
  • aggregatable fields

Vector search documents usually look like:

  • id
  • embedding (vector)
  • text or chunk_text
  • metadata (source, date, author, tags, ACLs)
  • optional sparse/keyword fields for filtering

Example:

{
  "id": "doc_123_chunk_4",
  "text": "To reset your password, go to ...",
  "embedding": [0.012, -0.84, ...],
  "metadata": {
    "doc_id": "doc_123",
    "chunk_index": 4,
    "source": "help_center",
    "language": "en"
  }
}

5) Build an ingestion pipeline

Migration is mostly an indexing problem.

Pipeline:

  1. Export documents from Elasticsearch
  2. Clean and normalize text
  3. Split into chunks
  4. Generate embeddings
  5. Store vectors + metadata in the new system
  6. Keep IDs stable for updates/deletes

Tips:

  • Use the original Elasticsearch _id as a stable reference.
  • Store doc_id and chunk_id separately.
  • Track versioning so you can re-embed content when text changes.
  • Make reindexing idempotent.

6) Recreate filtering and access control

Vector search is good at similarity, but most production search needs structured constraints:

  • language
  • tenant
  • document type
  • time range
  • permissions / ACLs

Make sure your vector system supports:

  • metadata filtering
  • post-filtering
  • pre-filtering
  • namespace/partitioning

If you have row-level security or ACLs, design that early.


7) Plan your query strategy

Vector search is usually not one query type; it’s a ranking strategy.

Common query flow:

  1. Embed the user query
  2. Retrieve top-k nearest chunks
  3. Apply metadata filters
  4. Optionally combine with BM25/keyword results
  5. Optionally rerank with a cross-encoder or LLM reranker

Hybrid retrieval is often best:

  • lexical search helps with exact names, IDs, error codes
  • vector search helps with intent and paraphrase matching

8) Evaluate before cutting over

Don’t migrate blindly.

Build an evaluation set:

  • 50–500 real queries
  • human-labeled relevant docs/chunks
  • measure:
    • recall@k
    • precision@k
    • MRR / nDCG
    • latency
    • cost

Compare:

  • Elasticsearch-only
  • vector-only
  • hybrid

In many cases, hybrid wins.


9) Run in parallel

A safe migration strategy:

Phase 1: Dual-write

Write new/changed content to:

  • Elasticsearch
  • vector index

Phase 2: Shadow queries

Send queries to the vector system in the background and compare results.

Phase 3: Hybrid production

Use vector search for ranking or fallback while keeping Elasticsearch live.

Phase 4: Gradual cutover

Switch traffic by percentage or use-case.


10) Handle updates, deletes, and freshness

This is a common gotcha.

You need:

  • delete vectors when source docs are deleted
  • re-embed when content changes
  • handle partial updates carefully
  • maintain sync between source of truth and search stores

A good pattern is:

  • source of truth in your app DB or document store
  • search indexes are derived artifacts
  • use events/CDC to update both Elasticsearch and vector index

11) What you lose vs Elasticsearch

Vector search does not naturally replace:

  • complex aggregations
  • exact phrase/term queries
  • faceting at scale
  • rich boolean query DSL
  • advanced text analyzers

If you rely heavily on those, keep Elasticsearch for that part.


12) Typical migration patterns

Pattern 1: Add semantic search to existing Elasticsearch

  • Keep Elasticsearch
  • Add embeddings fields or vector index
  • Hybrid queries
  • Lowest migration risk

Pattern 2: Split responsibilities

  • Elasticsearch = filters, aggregations, keyword search
  • Vector DB = semantic retrieval
  • App merges results

Pattern 3: Full move for RAG

  • Store chunks + embeddings in vector DB
  • Only metadata and source docs in relational DB or object storage
  • Elasticsearch retired or minimized

13) Simple migration checklist

  • Define search use cases
  • Pick embedding model
  • Decide document vs chunk granularity
  • Choose vector store or Elasticsearch vector support
  • Design schema with metadata filters
  • Build embedding + indexing pipeline
  • Set up dual-write
  • Create evaluation dataset
  • Compare lexical vs semantic vs hybrid
  • Add reranking if needed
  • Run shadow traffic
  • Gradually cut over

14) Recommended practical approach

If you’re unsure, start with:

  1. Keep Elasticsearch
  2. Add embeddings for chunks
  3. Use hybrid retrieval
  4. Measure search quality
  5. Only replace components that clearly benefit

That’s usually the safest and most effective migration path.


If you want, I can also give you:

  • a step-by-step migration plan for your specific stack,
  • an Elasticsearch → vector DB schema mapping,
  • or a Python example for dual indexing and hybrid retrieval.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.