<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title><![CDATA[Sunile Manjee - Elasticsearch Labs]]></title>
    <description><![CDATA[Articles and tutorials from the Search team at Elastic]]></description>
    <copyright><![CDATA[© 2026. Elasticsearch B.V. All Rights Reserved]]></copyright>
    <image>
      <title><![CDATA[Sunile Manjee - Elasticsearch Labs]]></title>
      <url>https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1121c0bf0e8a6e65/6a88da6340a1841030ef456f/search-labs-thumbnail.png</url>
      <link>https://www.elastic.co/search-labs/author/sunile-manjee</link>
    </image>
    <link>https://www.elastic.co/search-labs/author/sunile-manjee</link>
    <atom:link href="https://www.elastic.co/search-labs/rss/author/sunile-manjee.xml" rel="self" type="application/rss+xml"/>
    <language><![CDATA[en]]></language>
    <lastBuildDate>Sat, 19 Sep 2026 21:25:21 GMT</lastBuildDate>
  <item>
    <title><![CDATA[Intelligent RAG data chunking: Fetch surrounding chunks]]></title>
    <description><![CDATA[Learn about data chunking in RAG and explore fetch surrounding chunking, a pattern in RAG that uses chunking and Elasticsearch to refine LLM responses.]]></description>
    <content:encoded><![CDATA[<p>In the realm of Retrieval-Augmented Generation (RAG), one persistent challenge is finding the optimal amount of data to feed into a Large Language Model (LLM). Too little data results in insufficient or inaccurate responses, while too much data leads to vague answers. This delicate balance inspired me to develop a <a href="https://ela.st/fetch-surrounding-chunks">notebook</a> focusing on intelligent chunking and leveraging Elasticsearch vector database.</p><p>This blog builds on that notebook and explores fetch surrounding chunking, an emerging pattern in RAG that uses intelligent chunking and Elasticsearch vector database to optimize LLM responses. The approach balances data input to enhance the accuracy and relevance of LLM-generated answers through semantic hybrid search.</p><h2>The motivation: A refined approach to RAG data chunking</h2><p>The primary motivation behind building <a href="https://ela.st/fetch-surrounding-chunks">this notebook</a> was to demonstrate a refined approach to RAG by addressing the challenge of data chunking. Traditional methods often fall short in dynamically adjusting the data size fed to LLMs, either overwhelming the model with too much context or starving it with too little. This notebook aims to strike the right balance, providing just enough information for the LLM to generate precise and contextually relevant responses. However, it must be noted that there is no one-size-fits-all solution.</p><p>This method works especially well with books and similar texts where content flows within longer sections or chapters. However, it may require adaptation for texts structured into shorter, distinct sections, such as research papers or articles, where each segment might cover a different topic. In such cases, additional strategies may be necessary to effectively chunk and retrieve related content.</p><h2>The methodology: Intelligent RAG data chunking</h2><h3>Fetch surrounding chunks</h3><p>The core idea is to partition the source text into manageable chunks, ensuring each chunk contains just the right amount of information. For this demonstration, I used text from "Harry Potter and the Sorcerer's Stone." The text was partitioned into chapters, and each chapter was further divided into smaller chunks. These chunks, along with their dense and sparse (ELSER) vector representations, were indexed in the Elasticsearch vector database.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt6bcc905a1653ca3a/6a1711357d8d670d9970e846/23b210ce29f47f8a872d300ef01fca901d1e80ab-1163x548.png" alt="architecture" /><h3>Assigning numbers to chunks</h3><p>Each chunk within a chapter was assigned a sequential integer, allowing us to identify its position. When a matching chunk is found, the chapter number and chunk number are used to retrieve surrounding chunks, providing additional context for the LLM.</p><h3>Vector database in Elasticsearch</h3><p>These chunks and their vector representations were ingested into an Elasticsearch Cloud instance. Elasticsearch's robust vector search capabilities make it ideal for hosting these chunks, allowing for efficient retrieval of the most relevant chunks based on the semantic content or text match of a user's query.</p><h3>AI search</h3><p>To retrieve the relevant chunks, I employed a hybrid search strategy using dense vector comparisons, sparse vector comparisons, and text search in parallel. This multi-faceted approach ensures that the search results are both semantically rich and contextually accurate. A query is issued to find the matched chunk, which returns the chunk number and chapter. Surrounding chunks for that chapter are then fetched based on the matched chunk.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte879d45ec9558b9e/6a171137b339d50e9776a0be/62d3cb6d9cddcecda359bc1fd808b52cd0f23864-1440x778.png" alt="architecture" /><h2>The RAG pattern</h2><p>When a query is made, the search flow performs the following steps:</p><ol><li><p><strong>Query analysis:</strong> The user's query is translated into dense and sparse vectors to retrieve the most relevant chunks from the Elasticsearch index.</p></li><li><p><strong>Chunk retrieval:</strong> Using the AI search strategy, the system retrieves the top relevant chunks.</p></li><li><p><strong>Contextual expansion:</strong> Adjacent chunks (n-1 and n+1) are also retrieved to provide a more comprehensive context. If the chunk is the last in the chapter, it fetches n-1 and n-2; if it's the first, it fetches n+1 and n+2.</p></li><li><p><strong>LLM response:</strong> These intelligently selected chunks are then fed into the LLM, ensuring it receives the optimal amount of information to generate a precise and contextually relevant response.</p></li></ol><h2>Why intelligent RAG data chunking matters</h2><p>This approach addresses a critical aspect of RAG by optimizing the input data fed to LLMs. By leveraging intelligent chunking and hybrid semantic search, this method enhances the accuracy and relevance of the responses generated by LLMs. It showcases a pattern that can be widely applied in various applications within the RAG space, from customer support to content generation and beyond.</p><h2>Conclusion</h2><p><a href="https://ela.st/fetch-surrounding-chunks">This notebook</a> underscores the importance of intelligent data chunking in the RAG framework and demonstrates how Elasticsearch vector database can be leveraged to achieve optimal results. By ensuring the LLM receives just the right amount of information, this methodology paves the way for more accurate and contextually rich responses, enhancing the overall effectiveness of RAG systems.</p>]]></content:encoded>
    <link>https://www.elastic.co/search-labs/blog/advanced-chunking-fetch-surrounding-chunks</link>
    <guid isPermaLink="true">https://www.elastic.co/search-labs/blog/advanced-chunking-fetch-surrounding-chunks</guid>
    <category><![CDATA[AI]]></category>
    <category><![CDATA[Vector Database]]></category>
    <category><![CDATA[Python]]></category>
    <dc:creator><![CDATA[Sunile Manjee]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt17ba5b693b94a883/6a171139acf0880723be9c49/4467ccd71baaae7422b9b5df9a8612eec4af1bd2-1024x1024.png" length="0" type="image/png"/>
    <pubDate>Tue, 11 Jun 2024 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Avatar assisted & dialogue driven voice to RAG search]]></title>
    <description><![CDATA[Create avatar-assisted voice search experience by integrating speech-to-text, semantic search, RAG and a synthesized avatar for responses.]]></description>
    <content:encoded><![CDATA[<h2>The evolution of search</h2><p>Search has evolved from simple text queries yielding straightforward results to a complex system accommodating various formats like text, images, videos, and questions.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt24559d31d5b7b8f6/6a170b206f7f04db68914857/128bd2fe93461638e6ac28ca994a07c5a21e9c70-1440x659.png" alt="Legacy Search" /><p>Search not too long ago comprised of a text query and relevant results. Today's search results are enhanced with generative AI, machine learning, and interactive chat features, offering a richer, more dynamic, and contextually relevant user experience. Additionally, voice search and speech avatars have transformed traditional search, offering a more interactive and convenient user experience.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd19b4894abd43db2/6a170b22cf4f25868db2d18b/1ebe15a22c031bc439cb2500c21d1c60f79b008c-1440x781.png" alt="Search today" /><h3>The desire for dialogue in search</h3><p>In a realm where dialogue underpins every interaction, whether with fellow humans or bots, shouldn't our search experiences reflect this fundamental aspect? Envision the vast array of document corpora residing within an enterprise. Naturally, this environment sparks curiosity and a multitude of questions, leading to subsequent inquiries. This innate human trait drives us to seek answers, delve deeper following initial responses, and continuously explore. Yet, traditional question-and-answer mechanisms fall short, as they often disregard the context of preceding exchanges, leading to a disjointed and laborious process that feels unnatural and prompts users to disengage prematurely.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1ec8ee317d02777e/6a170b238b73cb33a818a046/f3feb0843430a550151182aba95648ce5b45820b-1440x766.png" alt="you have questions" /><h3>Beyond question and answer search</h3><p>Consider the act of using a television to search for content, such as seeking action movies featuring Nicolas Cage. While most current systems adeptly provide relevant results, the inquiry rarely ends there. Subsequent questions, such as inquiring about the runtime or release dates of these movies, are a natural progression in our quest for information. However, standard search applications are not designed to facilitate a continuous dialogue; they are structured around isolated question-and-answer formats, which limits the depth of interaction and exploration.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8ae209de746281fb/6a170b2566c4f994d9f8c043/60e914ec7dc1809b0f8a18eb2ec186fa3f2e890b-1006x430.png" alt="results" /><h2>Avatar assisted voice search experience</h2><p>This is where the concept of an avatar-assisted search experience comes into play, especially in scenarios where users, myself included, prefer direct answers without the need to sift through information. Occasionally, we desire the convenience of having answers delivered to us, bypassing the effort of reading through content. The development of an avatar to generate responses could further modernize this interaction, providing a more engaging, efficient, and natural user experience.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt3a6145eda1e0487f/6a170b2714b2704159e3c625/4e77349fb83be542c9817a65cb6a905e18879f6c-1116x1174.png" alt="results" /><h2>Live demo: creating an avatar assisted voice search experience</h2><p>This demo showcases a seamless integration of speech-to-text, Elasticsearch's semantic search capabilities, Azure OpenAI's RAG, and a synthesized avatar for responses.</p><h2>Integration details</h2><h4>Speech to search</h4><p>The advanced search experience begins with user voice interactions, which are converted into text by Azure Speech to Text, forming the basis of the search query. This query is then processed through Elasticsearch, using the ELSER, to retrieve relevant documents, such as TV guides listing “action movies featuring Nicolas Cage.” This ensures precision and relevance in the search results.</p><h4>RAG &amp; cache</h4><p>In the enhanced search framework, merely fetching documents isn't enough. Azure OpenAI's GPT-4 refines raw data into understandable responses, ensuring smooth conversation flow. Additionally, Elasticsearch boosts efficiency as a GenAI caching layer, recycling answers for related queries, thus conserving resources. For example, if there's a cached response for "action movies featuring Nicolas Cage," the caching API will swiftly use this for similar questions like “Nicolas Cage high-intensity movies,” accelerating the search experience.</p><h4>Avatar response generation</h4><p>The experience is further enriched with an avatar response feature, powered by Azure Synthesizer, adding a visual and auditory dimension that surpasses traditional text-based interfaces. This creates a more engaging and interactive user experience, integrating various advanced technologies to deliver a dynamic, intuitive, and compelling search experience.</p><h2>Summary</h2><p>The shift from traditional Google searches to platforms like ChatGPT for answering queries illustrates a broader trend: our preference for dialogue over static information retrieval. This predilection underscores the importance for enterprises to adopt a more intuitive and conversational approach in their search functionalities. By embracing this paradigm, businesses can better align with the natural human inclination towards dialogue, thereby enhancing the overall search and discovery process within their data ecosystems.</p><h2>Demo assets</h2><p>Still curious, here is the <a href="https://github.com/sunileman/voice-movie-search">link to the source code</a>.</p>]]></content:encoded>
    <link>https://www.elastic.co/search-labs/blog/avatar-assisted-dialogue-driven-voice-to-rag-search</link>
    <guid isPermaLink="true">https://www.elastic.co/search-labs/blog/avatar-assisted-dialogue-driven-voice-to-rag-search</guid>
    <category><![CDATA[AI]]></category>
    <category><![CDATA[Vector Database]]></category>
    <dc:creator><![CDATA[Sunile Manjee]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd3572b96ad92d331/6a170b29b339d560d0769fd3/9b274d1191d203babb55dc7693897fd278df1a09-1024x1024.png" length="0" type="image/png"/>
    <pubDate>Fri, 08 Mar 2024 00:00:00 GMT</pubDate>
  </item>
  </channel>
</rss>