Definition

What is vector search?

Vector search leverages machine learning (ML) to capture the meaning and context of unstructured data, including text and images, transforming it into a numeric representation. Frequently used for semantic search, vector search finds similar data using approximate nearest neighbor (ANN) algorithms. Compared to traditional keyword search, vector search yields more relevant results and executes faster.

Video thumbnail

Why is vector search important?

How often have you looked for something, but you're not sure what it's called? You may know what it does or have a description. But without the keywords, you're left searching.

Vector search overcomes this limitation, allowing you to search by what you mean. It can quickly deliver answers to queries based on similarity search. That's because vector embedding captures the unstructured data beyond text, such as videos, images, and audio. You can enhance the search experience by combining vector search with filtering and aggregations to optimize relevance by implementing a hybrid search and combining it with traditional scoring.

How does a vector search engine work?

Vector search engines — known as vector databases, semantic, or cosine search — find the nearest neighbors to a given (vectorized) query.

Where traditional search relies on mentions of keywords, lexical similarity, and the frequency of word occurrences, vector search engines use distances in the embedding space to represent similarity. Finding related data becomes searching for nearest neighbors of your query.

Diagram of how a vector search engine works using vector embeddings
  • Vector embedding

    Vector embeddings are the numeric representation of data and related context, stored in high dimensional (dense) vectors. Models that generate embeddings can be trained on millions of examples to deliver more relevant and accurate results. For some cases, numeric data that you collected or engineered to represent key features of your documents can be used as embeddings. All you need is the ability to search efficiently.

  • Similarity score

    At the core of a vector search engine is the idea that if data and documents are alike, their vectors will be similar. By indexing both queries and documents with vector embeddings, you find similar documents as the nearest neighbors of your query.

  • ANN algorithm

    Traditional nearest neighbor algorithms, like k-nearest neighbor algorithm (kNN), lead to excessive execution times and zaps computational resources. ANN sacrifices perfect accuracy in exchange for executing efficiently in high dimensional embedding spaces, at scale.

Vector search use cases

Vector search not only powers the next generation of search experiences, it opens the door to a range of new possibilities.

  • Vector search powers semantic or similarity search. Since the meaning and context is captured in the embedding, vector search finds what users mean, without requiring an exact keyword match. It works with textual data (documents), images, and audio. Easily and quickly find products that are similar or related to their query.

  • Recommendations

    The model that generates the embedding learns to recognize similar documents and their vectors in the embedding space. For example, an application may recommend movies or products that others who purchased the one you bought also liked. But, make sure that the embeddings are derived with some measure of popularity or likability as the target metric.

    Vector distances can be combined with other metrics so that recommendations achieve multiple goals. For example, rank product recommendations by satisfaction scores and revenue potential.

  • Question answering

    Converting documents to text embeddings can be combined with modern natural language processing (NLP) to deliver full text answers to questions. This approach spares users from studying lengthy manuals and empowers your teams to provide answers more quickly.

    A "question answering" transformer model can take the text embedding representation for both the knowledge base of documents and your current question to deliver the closest match as an "answer."

Don't stop at just semantic search!

  • Browse unstructured data

    Search any unstructured data. You can create embeddings for text, images, audio, or sensor measurements.

  • Filter on metadata

    Filter vector search results using metadata. Maintain recall without sacrificing speed by applying a filter in line with approximate nearest neighbor (ANN) search.

  • Re-rank search results

    Vector similarities can be interpreted as similarity scores that you can re-rank with other data. That includes static fields already in your vector search database, and new properties by applying machine learning models.

  • Hybrid scoring

    To further optimize, combine vector similarities with BM25F scores, known as hybrid scoring. This allows you to have images ranked by vector similarity while implementing BM25F, which can provide better rankings for text.

How to get started

Vector search and NLP made easy with Elastic

You don’t have to move mountains to implement vector search and apply NLP models. With the elasticsearch Relevance Engine™ (ESRE), you get a toolkit for building AI search applications that can be used with Generative AI and large language models (LLMs).

With ESRE, you can build innovative search applications, generate embeddings, store and search vectors, and implement semantic search with Elastic’s Learned Sparse Encoder. Learn more about how to use elasticsearch as your vector database or try out this self-paced hands-on learning for vector search.

Video thumbnail
  • Large language models

    Give LLMs business-specific information using your private data (not just publicly trained data). Use elasticsearch and access Generative AI with APIs and plugins integrated with the LLM of your choice.

  • Text embedding and more

    Learn how to assign sentiments and other categories to your data with Elastic. Apply named entity recognition (NER) to improve search experiences with additional metadata.