The Evolution of Search: From Keywords to AI

Jorge G
11 min readSep 27, 2023

--

Introduction

In today’s digital age, search algorithms are the invisible engines that power our quest for information, be it a simple recipe or a critical business document. They have become an integral part of our daily lives and are fundamental to the success of businesses worldwide. This article aims to be your comprehensive guide to understanding these algorithms. From their underlying mechanisms to the various types that have evolved over time, we’ll explore how search technology works and why it matters. Whether you’re a developer, a data scientist, or simply someone curious about the intricacies of search, this article is designed to be your go-to resource.

The history of search technology is a fascinating journey that mirrors the evolution of the internet itself. Early search engines like Yahoo! and AltaVista laid the groundwork, but it was the advent of Google and Bing that truly revolutionized the way we search for information. These platforms introduced sophisticated algorithms that could understand not just keywords but also the context and relevance of a query.

Before the era of modern search engines, classical tools like Lucene, Solr, and Elasticsearch were the go-to solutions for building search capabilities into applications. These tools laid the foundation for many of the search algorithms we use today, offering features like text indexing and Boolean search capabilities.

As we delve into the complexities of search, it’s worth noting the role of Azure in this evolving landscape. Microsoft’s Azure platform offers a range of search services and capabilities that are pushing the boundaries of what’s possible, from keyword-based search to more advanced AI-driven solutions.

The landscape of search technology is continually evolving. The shift from simple keyword-based search to more complex semantic and vector search methods has been significant. The role of artificial intelligence and machine learning in shaping modern search algorithms cannot be overstated, offering capabilities like natural language understanding and real-time personalization.

Understanding the Underlying Mechanisms of Search Algorithms

The magic of search technology lies in its ability to sift through vast amounts of data to find what’s relevant to your query. But what powers this magic? At the core of any search algorithm are three key components: indexing, search, and ranking.

Indexing

Indexing is the first step in the search process. It involves scanning and organizing data into a structure that can be easily traversed. Two common types of indexing methods are the inverted index and the forward index. The inverted index stores a list of occurrences for each term, while the forward index stores a list of terms for each document. Both methods have their advantages and are used depending on the specific requirements of a search algorithm.

Search Process

Once the data is indexed, the next step is the search itself. This involves parsing the user’s query and expanding it, if necessary, to include synonyms or related terms. The search algorithm then scans the index to find relevant data, based on the query.

Diagram depicting a search request in Azure Cognitive Search

Ranking Algorithms

After identifying a list of potentially relevant results, the algorithm ranks them based on various factors. Commonly used ranking algorithms include BM25, which considers term frequency and inverse document frequency, PageRank, which evaluates the quality of links to a page, and Learning to Rank (LTR), which uses machine learning to optimize the ranking of search results.

It’s worth noting that these core components — indexing, search, and ranking — are common across different types of search algorithms. Whether it’s traditional keyword-based search or more advanced methods like semantic and vector search, these foundational elements remain consistent.

Traditional Search Algorithms

Traditional search algorithms have been the cornerstone of information retrieval for many years. Originating from simple keyword-based methods, these algorithms match query terms directly with terms found in the data. While effective for straightforward queries, keyword-based search often falls short when it comes to understanding the context or semantics behind a query.

Taking a step further, Boolean search allows for a more refined query process. By combining keywords with operators like AND, OR, and NOT, Boolean search offers users a way to produce more relevant results. For example, a query like “apple AND orange NOT banana” would yield results that contain both “apple” and “orange,” but exclude “banana,” providing a more controlled search experience.

Another layer of complexity is added with wildcard search, which uses symbols like ‘*’ or ‘?’ to represent unknown letters in a word. This is particularly useful for imprecise queries but can also lead to a lot of irrelevant results.

To improve the efficiency and relevance of search results, traditional search algorithms often employ text analysis techniques. Methods like stemming, lemmatization, and tokenization break down words to their root forms or tokenize sentences into individual words. These techniques serve as the building blocks for more advanced algorithms and are fundamental in traditional search.

In terms of ranking, traditional search often relies on simple algorithms like term frequency (TF) and inverse document frequency (IDF). These algorithms count the number of times a term appears in a document or across all documents to rank the results, providing a basic but effective way to determine relevance.

However, the primary limitations of traditional search algorithms lie in their inability to understand context, semantics, or user intent. For instance:

  • Ambiguity: Traditional search algorithms struggle with words that have multiple meanings. For example, the word “apple” could refer to the fruit or the tech company. A keyword-based search might not distinguish between these contexts, leading to mixed results.
  • Synonyms: These algorithms often miss out on relevant results that use synonyms of the query terms. For example, a search for “automobile” might not return results that use the word “car.”
  • Complex Queries: Traditional search is not well-suited for complex queries that involve understanding the relationship between different terms. For example, “best way to peel an apple” would require understanding the intent behind the query, something traditional search algorithms are not equipped to do.
Representation of the different semantic spaces of the word capital.

These limitations often lead to irrelevant or incomplete search results, highlighting the need for more advanced search algorithms.

While traditional search algorithms have their limitations, they laid the groundwork for the development of more advanced methods like semantic and vector search, which we will explore in subsequent sections.

Semantic Search

Semantic search algorithms represent a significant evolution in the field of information retrieval. Unlike traditional search algorithms, which primarily focus on keyword matching and Boolean logic, semantic search aims to understand the intent and context behind a user’s query. This deeper level of understanding is achieved through advanced Natural Language Processing (NLP) techniques such as Named Entity Recognition and Language Models.

The power of semantic search lies in its ability to interpret user intent. For example, if someone searches for “Apple,” the algorithm can differentiate between the tech company and the fruit based on the context in which the search is made. This is a stark contrast to traditional search methods, which would simply look for the keyword “Apple” in the data, often leading to mixed or irrelevant results.

One of the key technologies enabling semantic search is Natural Language Processing (NLP). Named Entity Recognition can identify specific entities like names of people, organizations, or locations in a text. Advanced Language Models can predict the likelihood of a particular sequence of words, adding another layer of context to the search.

Azure Cognitive Search elevates semantic search by offering a fully managed cloud search service with AI enrichment features. These features can extract additional information from the content you are indexing, thereby improving the search experience. When you enable semantic search on your Azure Cognitive Search service, it extends the query execution pipeline by adding secondary ranking over an initial result set scored using the BM25 algorithm. It uses multi-lingual, deep learning models adapted from Microsoft Bing to promote the most semantically relevant results. Moreover, Azure Cognitive Search can extract and return captions and answers in the response, which can be rendered on a search page to enhance the user’s experience.

Vector Search

Vector search is a game-changer in the realm of search technology, offering a more nuanced way to find information. Unlike traditional search methods that rely solely on keyword matching, vector search goes deeper to understand the semantic relationships within the data. The cornerstone of this approach is the use of embeddings. These are high-dimensional vectors generated by machine learning models that capture the semantic essence of the content. To make this work, documents in your database need to be transformed into these embeddings, essentially turning them into condensed, mathematical representations of their meanings. Each dimension in this high-dimensional space represents a different aspect or feature of the content, allowing for a rich, multi-faceted representation. When a query comes in, it’s also transformed into an embedding. By comparing the query’s embedding with the embeddings of the transformed documents in your database, vector search identifies the most relevant matches. Azure OpenAI offers specialized models like “text-embedding-ada-002” to generate these intricate embeddings, capturing not just the literal meanings but also the relationships and nuanced contexts within the data.

Azure OpenAI Service embeddings tutorial — Azure OpenAI | Microsoft Learn

Now, once we have these embeddings, how do we search through them? This is where algorithms like Cosine Similarity, K-Nearest Neighbors (KNN), Approximate Nearest Neighbors (ANN), Locality-Sensitive Hashing (LSH), and Hierarchical Navigable Small World (HNSW) come into play. To oversimplify:

  • Cosine Similarity measures the angle between two vectors, but it’s computationally expensive on large datasets.
  • KNN finds the closest vectors in the space but can be slow.
  • ANN is like a faster, albeit less accurate, version of KNN.
  • LSH hashes similar items into the same “buckets” for quicker retrieval.
  • HNSW is an advanced technique optimized for high-recall, low-latency applications.

Azure is a hub for vector search solutions, offering services like Azure Cognitive Search, Azure CosmosDB, Azure Data Explorer, Azure SQL, Azure PostgreSQL and more. When choosing a vector database, you have a variety of options, both open-source like Milvus, Weaviate, Qdrant, or Pinecone, and enterprise solutions like Elasticsearch and Redis. Your choice should consider factors such as:

  • Scalability: Can it handle your data volume?
  • Query Performance: How fast can it retrieve results?
  • Data Types: Does it support the kind of data you’re working with?

Note: The landscape of vector databases is rich, offering solutions that cater to different needs and scales. Your choice will significantly impact the performance and capabilities of your search solution.

Source: https://blog.det.life/why-you-shouldnt-invest-in-vector-databases-c0cd3f59d23c

Azure Cognitive Search elevates vector search by offering a fully managed service with built-in vector search functionalities. It not only allows for the indexing and retrieval of vector embeddings but also integrates seamlessly with Azure OpenAI for generating these embeddings. It supports a wide range of query types, including hybrid queries that combine traditional text fields with vector fields.

https://learn.microsoft.com/en-us/azure/search/vector-search-overview

While vector search offers unparalleled advantages like high accuracy and complex query handling, it’s not without challenges. These include the computational cost and the quality of embeddings, which can impact the search results.

Hybrid Search

In the ever-evolving landscape of search technology, hybrid search algorithms emerge as a powerful approach that combines the best of traditional, semantic, and vector search methods. This “best of all worlds” strategy leverages the strengths of each type of search algorithm to create a more versatile and accurate search experience. For example, traditional search can handle straightforward keyword queries, semantic search can understand the context, and vector search can capture the nuanced relationships between data points.

Technically, hybrid search algorithms often use a mix of techniques like BM25F for text-based search and cosine similarity for vector-based search. These algorithms work in tandem to rank and retrieve the most relevant results based on multiple criteria, offering a more holistic search experience.

Azure plays a significant role in the realm of hybrid search. Services like Azure Cognitive Search offer the flexibility to implement hybrid search solutions by combining traditional searchable text fields with vector fields. This allows for a seamless integration of various search methods, making Azure a one-stop solution for complex search requirements.

Present Trends and Developments in Search Technologies

As we look toward the horizon, the landscape of search technologies is anything but static. Innovations are continually pushing the boundaries, offering more efficient, intuitive, and personalized search experiences. One of the most exciting advancements is the integration of generative AI models like GPT-4 into search functionalities. These models can understand context, generate human-like responses, and even predict user intent, making the search process more interactive and engaging.

A standout innovation that deserves special attention is the Retrieval Augmented Generation (RAG) method. At its core, RAG is designed to provide more accurate and contextually relevant answers in a conversational search setting. Here’s how it works: when a question is posed, RAG first transforms it into a search query against a knowledge base or database. It then retrieves a set of relevant documents or data points. These retrieved items, along with the original question, are fed into a Large Language Model (LLM) like ChatGPT. The LLM then generates a factual, coherent, and contextually appropriate response based on this combined information. This two-step process — first retrieval and then generation — makes RAG particularly effective for scenarios where the context and relevance of the answer are crucial.

Note: In the following url you will find an article on how to create your own RAG application using Azure Cognitive Search: RAG and generative AI — Azure Cognitive Search | Microsoft Learn

Retrieval Augmented Generation

Personalization and context-aware search are other areas where significant advancements are expected. Imagine a search engine that not only knows what you’re looking for but also understands the context in which you’re asking it. Such a system could provide answers that are not just accurate but also contextually relevant, thereby saving time and reducing the cognitive load on the user.

The future is also looking increasingly multimodal. As technology evolves, we’re moving beyond text-based queries to a world where searches can be conducted through voice, images, and even videos. This multimodal approach not only makes search more accessible but also more natural and intuitive.

Conclusion

In the ever-changing landscape of search technologies, we’ve come a long way from simple keyword-based searches to complex algorithms that understand context, semantics, and even the nuances of human language. The integration of generative AI models, advanced methods like Retrieval Augmented Generation (RAG), and the shift towards multimodal and personalized search are not just trends but significant milestones that are redefining what we can expect from search engines. These advancements are not merely academic exercises; they have practical implications across industries, from e-commerce to healthcare, enhancing user experience and operational efficiency.

As we look to the future, it’s clear that the field of search technology will continue to evolve, driven by innovations in AI and machine learning. Azure Cognitive Search is one of the services that is quickly adopting these latest advancements, offering an interesting platform that aims to meet the diverse needs of modern enterprises. While it’s an evolving service, its rapid adoption of AI technologies makes it a noteworthy player in this space. Whether you’re a developer, a business leader, or an end-user, the future of search promises to be more intuitive, efficient, and responsive than ever before, opening new avenues for information retrieval and knowledge discovery.

--

--

Jorge G

Cloud Solution Architect in Data & AI at Microsoft