Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Semantic Search in Practice with MongoDB and Vo...

Avatar for life michael life michael
September 15, 2026

Semantic Search in Practice with MongoDB and Voyage AI

Semantic search changes the way we think about searching data. Instead of relying only on exact keywords, semantic search attempts to understand the meaning and intent behind a query and retrieve information that is conceptually related to what the user is looking for. This presentation, “Semantic Search in Practice – Implemented with MongoDB and Voyage AI,” introduces the fundamental ideas behind semantic search and demonstrates how they can be implemented in a practical software application.

The presentation begins with the basic concepts of semantic understanding, semantic search, vector embeddings, and embedding models. It explains how words, sentences, and other types of data can be represented as numerical vectors in a multidimensional space, where semantically similar information tends to be positioned closer together. It also introduces several common techniques for measuring similarity between vectors, including cosine similarity, Euclidean distance, and dot product similarity.

The practical part of the presentation demonstrates how to generate embeddings using Voyage AI, how to create embeddings for documents and search queries, and how to rank documents according to their semantic similarity. Python code samples show the complete process, including generating document embeddings, generating query embeddings, calculating similarity, and retrieving the most relevant results.

The presentation then moves from a simple in-memory implementation to a more realistic architecture using MongoDB Atlas. It explains how embeddings can be stored together with the original MongoDB documents, how to create a Vector Search Index, how to generate an embedding for a user's query, and how to perform semantic search using MongoDB's $vectorSearch aggregation stage.

The slides also connect semantic search with RAG — Retrieval-Augmented Generation. Once data is represented by embeddings and can be retrieved through vector search, it can be supplied as contextual information to generative AI applications, helping them produce answers based on relevant external information. The presentation concludes with MongoDB's autoEmbed capability, which can automatically generate Voyage AI embeddings from document fields at index time, reducing the need to calculate and store embeddings manually.

This presentation is intended for software developers who want to understand what semantic search is, how vector embeddings make it possible, and how the complete process can be implemented using Python, MongoDB, and Voyage AI.

You can find the post that summarizes this meetup at https://lifemichael.com/en/semantic-search-in-practice-with-mongodb.

You can find more information about that meetup at https://www.meetup.com/lifemichael/events/315942806

Avatar for life michael

life michael

September 15, 2026

More Decks by life michael

Other Decks in Programming

Transcript

  1. Semantic Search in Practice Implemented with MongoDB and Voyage AI

    0001000111001100 1100001000111001 0100010001110011 1000100011100110 1010000100011100 Haim Michael blog.lifemichael.com
  2. My name is Haim Michael. I live in Tel Aviv,

    and I am the CEO & founder of Zindell Technologies, Ltd. I have been into programming since my childhood. I have extensive experience with Java (30+ yrs), JavaScript (30+ yrs), C++ (30+ yrs), C# (20+ yrs), TypeScript (12+ yrs), Python (15+ yrs), PHP (20+ yrs), Scala (16+ yrs), and Kotlin (12+ yrs). blog.lifemichael.com Tel-Aviv
  3. Zindell Technologies zindell.com nana.events xtremej.dev xtremejs.dev lifemichael.com prompo.pro xtremepython.dev xtremeai.dev

    jacado.games ngager.pro zindrex.com blog.lifemichael.com About Zindell Technologies
  4. My passion lies in teaching and lifelong learning. I continuously

    learn and evolve. Learning takes place in various forms. Learning is not limited to the formal educational systems. You thrive when you explore topics that genuinely interest you. blog.lifemichael.com Passion for Learning
  5. B.Sc. in Economics & Accounting Tel-Aviv University MBA (Information Systems

    Management) Teaching advanced topics in software development at leading academic institutions. Teaching Today Holon Institute of Technology Bar Ilan University Ben Gurion University Reichman University Tel-Aviv University Technion Institute of Technology blog.lifemichael.com My Academic Background
  6. Functional Programming Micro Services Design Patterns (Scala) Classic Design Patterns

    FED Concurrent Programming (Threads in Java & Coroutines in Kotlin) AI Agents Orchestration Design Patterns Asynchronous Server-Side Development (Node.js & MongoDB) Events Driven Architecture Spec-Driven Development with AI blog.lifemichael.com Academia
  7. Jacado - More Than 200 Games for Mobile Telephones –

    Years 2001- 2008 Zindell - Building AI Aligned Companies – Years 2026 - … nana.events prompo.ai zindrex.com ngager.pro jacado.games blog.lifemichael.com Passion to Build
  8. What is Semantic Understanding? When getting a result we wanted

    even thought we haven’t asked for it specifically. Imagine getting into a restaurant in a hot day and getting a cold glass of water even though you haven’t specifically asked to get it.
  9. What is Semantic Search? Semantic search is a search method

    that tries to understand the meaning and intent behind a query, rather than matching only exact keywords.
  10. Semantic Search Example When doing keyword search for: “cheap places

    to stay in Haifa” we will get documents containing those exact words only. Semantic search might also find content mentioning: “affordable accommodation in Haifa” because both phrases have a similar meanings.
  11. Semantic Search on Computer Computers have evolved as machines that

    can handle accurate searches only. How can computers perform semantic search? Semantic search is possible using vector embeddings. The vector embeddings help the computer to bridge the gap.
  12. What are Vector Embeddings? The vector embeddings are numerical representations

    of data, such as words, sentences or even images. We can imagine that when putting these numerical representations on a map, we will get similar data clustered together. Similar words, such as ‘kid’ and ‘child’ will be shown next to each other on the map.
  13. What are Embedding Models? The embedding models are AI models

    trained on large amounts of data. They learn patterns that allow them to convert any data into lists of numbers that represent its meaning.
  14. Embedding Models on MongoDB It is possible to use any

    embedding model on MongoDB. In the examples this presentation includes we will use embedding models that were developed by Voyage AI. We can easily access these embedding models using MongoDB Atlas Embedding & Reranking API.
  15. The Embedding & Reranking API There are two ways to

    access the MongoDB Atlas Embedding & Reranking API. We can either send HTTP requests on the API endpoint or use the Python SDK.
  16. Using The Voyage Embedding Model We can easily create an

    account at voyageai.com and then get API keys and use Voyage python library to start using their Embedding Models. https://docs.voyageai.com/docs
  17. Using The Voyage Embedding Model import voyageai vo = voyageai.Client(api_key="pa-hYuu8j9OtXsker89rUZ")

    texts = [ "We love chocolate", "Pizza is great! Ice creame as well.", "Drink water on a hot day" ] [ [0.017364630475640297, -0.06076261028647423, ... ], [0.432345345442640231, -0.12233434343647474, ... ], [[0.01736463047 [0.987345345442640543, -0.09233434343648897, ... ] 5640297, ] 0.060762610286 47423, result = vo.embed(texts, model="voyage-4-large", input_type="document") 0.018702523782 print(result.embeddings) 849312, 0.006020921748 131514, -
  18. Using The Voyage Embedding Model [ ] [0.017364630475640297, -0.06076261028647423, ...

    ], [0.432345345442640231, -0.12233434343647474, ... ], [0.987345345442640543, -0.09233434343648897, ... ] [[0.01736463047 The coordinate 5640297, - on each dimension is a number in between 0 and 1. 0.060762610286 47423, Each coordinate helps position this phrase in meaning space 0.018702523782 in a multi dimension space (hundreds of dimensions) 849312, 0.006020921748 131514, -
  19. Dot Product Similarity Measuring the dot product between every two

    (vectors) points is also a way to measure the similarity.
  20. Vector Embeddings Calculation When implementing a semantic search we will

    add the vector embedding to every document in our collection. When dealing with small amount of data we can generate the vector embeddings for each document during the execution of our code.
  21. Simple Semantic Search Code Sample documents = [item["description"] for item

    in data] query = "high mountains" doc_embeddings = vo.embed(texts=documents,model="voyage-4",input_type="document").embeddings query_embedding = vo.embed(texts=[query],model="voyage-4",input_type="query").embeddings[0] similarities = np.dot(doc_embeddings, query_embedding) ranked_indices = np.argsort(-similarities)
  22. Simple Semantic Search Code Sample for index in ranked_indices[:3]: print(data[index]["title"])

    print(documents[index][:100]) print("Similarity score: %f" % similarities[index])
  23. Simple Semantic Search Code Sample The Swiss Alps A mountainous

    region offering hiking, skiing Similarity score: 0.434079 Cappadocia A region known for unusual rock formations, underground cities Similarity score: 0.387080 The Norwegian Fjords Deep coastal inlets surrounded by steep mountains Similarity score: 0.368017
  24. Storing Embeddings in MongoDB MongoDB allows us to generate embeddings

    using Voyage AI and easily have them as part of the data we store on the MongoDB database. Using that we can avoid setting up a dedicated database for storing the embeddings and we can avoid generating these embeddings on the fly.
  25. Which Data to Embed We will embed any data we

    want to allow the user to semantically search for, such as product description, and users feedbacks.
  26. How to Store the Embeddings We will store the original

    data together with its embeddings. That will simplify querying the data.
  27. What is a RAG Application? RAG applications are AI applications

    that combine the use of a large language model with external information sources. RAG stands for Retrieval-Augmented Generation. Instead of asking the language model to answer only from what it learned during training, the application first retrieves relevant information from documents, databases, websites, or other sources, and then it gives that information to the model as context for generating the answer.
  28. RAG Applications and Embedding Vectors Once we have embeddings for

    our data, we can build applications that use RAG (Retrieval Augmented Generation). Such applications will combine vector search with generative AI to provide more accurate and contextually relevant responses.
  29. Using Vector Embeddings with Mongo DB The following code sample

    shows how easy it is to generate Voyage AI embeddings and store them in MongoDB Atlas.
  30. Using Vector Embeddings with Mongo DB data = [ {

    "title": "The Colosseum in Rome", "description": "An ancient amphitheater ... ruins.", "country": "Italy", }, ... ]
  31. Using Vector Embeddings with Mongo DB vo = voyageai.Client() client

    = pymongo.MongoClient(os.getenv("MONGODB_URI")) db = client["mydatabase"] collection = db["mycollection"] texts_to_embed = [item["description"] for item in data] result = vo.embed(texts_to_embed, model="voyage-4", input_type="document") for i, item in enumerate(data): item["embedding"] = result.embeddings[i]
  32. Creating Vector Search Index The following code creates a vector

    search index for the collection containing our documents and embeddings. Please note that it won’t work if you are using MongoDB free tier. If you are using a free tier make sure to create the vector search index on the MongoDB admin panel.
  33. Creating Vector Search Index from pymongo.operations import SearchIndexModel search_index_model =

    SearchIndexModel( definition={ "fields": [ {"numDimensions":1024, "path":"embedding", "similarity":"dotProduct", "type":"vector"} ] }, name="vector_index", type="vectorSearch" ) collection.create_search_index(model=search_index_model)
  34. Creating Vector Search Index We can alternatively create the vector

    search index at MongoDB online management panel. When using the free cluster this is the only way to create a vector search index.
  35. Generate Embeddings for The Query The following code creates the

    embeddings for the query. These embeddings are required for performing the vector search.
  36. Generate Embeddings for The Query query = "high mountains” query_embedding

    = vo.embed( [query], model="voyage-4", input_type="query").embeddings[0]
  37. The Semantic Search The following code will perform the semantic

    search using the vector search index that was created. Please note that you cannot perform it right after the documents were added. You need to wait till MongoDB atlas digest the new added documents and allow performing the semantic search.
  38. The Semantic Search results = collection.aggregate([ { "$vectorSearch": { "index":

    "vector_index", "path": "embedding", "queryVector": query_embedding, "numCandidates": 100, "limit": 10 } } ]) for doc in results: print(doc['title'])
  39. Auto-Embedding Vector Search Index The MongoDB's autoEmbed feature allows us

    having the voyage-4 embeddings be automatically generated from the description field at index time, eliminating the need to pre-compute and store embeddings manually.
  40. Q&A nana.events Thanks for attending my talk :) WhatsApp +972.54.6655837

    nana.events prompo.ai [email protected] https://blog.lifemichael.com Jacado You can download the code samples at jacado.games prompo.ai ngager.pro https://tinyurl.com/semanticsearchcodesamples Ddq d life michael lifemichael.com XtremeJ xtremej.dev life michael XtremeJS xtremejs.dev XtremePython xtremepython.dev XtremeAI xtremeai.dev meetup.com/lifemichael Monolith vs Microservices