Building a Production RAG-based Customer Support Assistant with Elasticsearch

elastic · Tech · 2024 · source Agentic: no · promotional bias: med · source-backed · extracted with prompt 0.5.4 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Customer support RAG over Elastic product knowledge

Elastic needed its Support Assistant to answer technically deep customer questions from support articles, product documentation, blogs, and internal knowledge while preserving role-based access and keeping retrieval precise enough that the LLM would not use irrelevant context.

Constraints:

Architecture

Elastic built the Support Assistant around a search-first RAG knowledge library in Elasticsearch. Support articles, product docs, blogs, labs content, and onboarding guides feed a unified index with document-level security. Crawlee jobs on Google Cloud Run ingest large site maps, ELSER enriches title and summary fields for semantic retrieval, BM25 scores larger content fields, and OpenAI-generated summaries/questions backfill missing metadata. The assistant retrieves concise, role-appropriate passages and sends them to the LLM as context.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  support-assistant[Support Assistant] --> hybrid-retriever[Hybrid Retriever]
  hybrid-retriever --> knowledge-library-index[Knowledge Library Index]
  support-articles[Support Articles] --> knowledge-library-index
  support-articles --> private-context-plugin[Private Context Plugin]
  documentation-crawlers[Documentation Crawlers] --> request-handlers[Request Handlers]
  request-handlers --> knowledge-library-index
  knowledge-library-index --> elser-semantic-search[ELSER Semantic Search]
  elser-semantic-search --> hybrid-retriever
  summary-enrichment-service[Summary Enrichment Service] --> openai-gpt[OpenAI GPT]
  summary-enrichment-service --> knowledge-library-index
  hybrid-retriever --> openai-gpt
  openai-gpt --> support-assistant
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Support Assistant Customer support chatbot that answers questions by grounding responses in Elastic search results. Hybrid Retriever, OpenAI GPT
Knowledge Library Index Unified Elasticsearch index holding article content, metadata, summaries, generated questions, and access controls. Support Articles, Documentation Crawlers, ELSER Semantic Search, Hybrid Retriever
Support Articles Knowledge-centered support articles authored by Support Engineers and stored in Elasticsearch. Knowledge Library Index, Private Context Plugin
Private Context Plugin EUI markdown plugin that parses internal-only context blocks for Support team use. Support Articles
Documentation Crawlers Crawlee-based Cloud Run jobs that ingest product documentation, blogs, labs content, and onboarding guides. Knowledge Library Index, Request Handlers
Request Handlers Document-type-specific parsers that choose relevant CSS/body content and avoid filler text in indexed documents. Documentation Crawlers, Knowledge Library Index
ELSER Semantic Search Elastic learned sparse embedding retrieval used on title and summary fields. Knowledge Library Index, Hybrid Retriever
Hybrid Retriever Combines semantic search over title/summary with BM25 over larger content fields to produce context for the assistant. Support Assistant, Knowledge Library Index, ELSER Semantic Search, OpenAI GPT
Summary Enrichment Service Cloud Run job using OpenAI GPT-3.5 Turbo to backfill missing document summaries and generated questions. Knowledge Library Index, OpenAI GPT
OpenAI GPT LLM used both for metadata enrichment and for final Support Assistant answer generation. Support Assistant, Summary Enrichment Service

Data flow

Support Engineers author knowledge articles and Elastic crawls official documentation/blog sources into Elasticsearch. Request handlers normalize page bodies, document-level security controls which records can be retrieved, ELSER creates semantic embeddings for searchable fields, OpenAI GPT-3.5 Turbo backfills summaries and questions where metadata is missing, and the Support Assistant uses hybrid search over title, summary, content, and generated question fields to assemble compact context for OpenAI.

4 supporting quotes
“The body of knowledge that we draw from for both search and the Elastic Support Assistant depends on three key activities”article, stated
“Our new architecture takes advantage of document level security to enable role-based access from a single index source.”article, stated
“The ingest process includes several hundred thousand documents and deals with complex site maps across Elastic properties.”article, stated
“One of our team’s engineers had the idea to instead use AI to do this. We created a new service which leveraged OpenAI GPT3.5 Turbo”article, stated

Why this architecture

Elastic framed the assistant as a retrieval and search-relevance problem, not a model-customization problem. RAG fit existing unstructured knowledge, gave immediate updates, enabled document-level access control, and reused Support Hub search infrastructure. Hybrid retrieval and AI-generated summaries targeted the concrete failure mode the team observed: too much irrelevant context made the LLM less accurate.

4 supporting quotes
“We explored fine-tuning our own model for the Support Assistant and instead landed on an RAG-based approach”article, stated
“4. Less maintenance: Search on the Support Hub and the Support Assistant share much of the same underlying infrastructure. We improved search results and a chatbot from the same work effort.”article, stated
“For our hybrid search approach in the Support Assistant, we use the title and summary fields for semantic search with BM25 on the much larger content field.”article, stated
“We initially passed larger text passages as context to the user question. This decreased the accuracy of the results”article, stated

Models used: ELSER · OpenAI GPT3.5 Turbo · OpenAI GPT

Scale

Alternatives considered (roads not taken)

Fine-tune a Support Assistant model

Rejected because: Elastic's available support data was unstructured and not in question-answer pairs, and the product knowledge needed fast updates and access filtering.

“Fine-tuning required question-answer pairing that did not match our data set and would be challenging to do at the scale of our data.”article, stated
“Real-time updates: Immediately incorporates new information by accessing up-to-date documents, ensuring current and relevant responses.”article, stated

Keep separate Swiftype and AppSearch article stores

Rejected because: The split was technical debt once Elasticsearch could provide the features needed for both internal and customer-facing articles.

“Our prior architecture had two separate storage methods for knowledge articles. One was a Swiftype instance used for customer facing articles and the other was through Elastic Appsearch for internal Support team articles.”article, stated
“This was tech debt on the part of our engineering team as Elasticsearch had already brought parity to several of the features we needed.”article, stated

Use the first 280 characters as document summaries

Rejected because: The simple heuristic produced poor search relevance, so Elastic used LLM-generated summaries and questions instead.

“The simplest approach was to take the first 280 characters of each document and use that as the summary. We tested this and found that it led to poor search relevancy.”article, stated
“The simplest approach was to take the first 280 characters of each document and use that as the summary. We tested this and found that it led to poor search relevancy.”article, stated

Crawl broad top-level site roots

Rejected because: Elastic needed technical documents and wanted to avoid duplicate or unhelpful content.

“When crawling websites we recommend starting with base urls that do not have overlapping content so as to avoid the ingestion of duplicates.”article, stated
“we crawl https://elastic.com/blog and https://www.elastic.co/search-labs/blog rather than elastic.co/ since our objective was technical documents.”article, stated

Patterns

rag-retrieval (knowledge-access)

Elastic retrieves concise, role-appropriate passages from a large support and documentation library before sending context to the LLM.

“RAG via Elasticsearch + Lucene enables the ability to not only find key passages within books across an entire library”article, stated
“By extracting this information and sending it to the large language model, we both save the user time and return an answer in natural language”article, stated

hybrid-search (retrieval-ranking)

The Support Assistant combines semantic retrieval over title/summary fields with BM25 over larger content fields.

“we use the title and summary fields for semantic search with BM25 on the much larger content field.”article, stated
“This enables the Support Assistant to have both speed and high relevance to the text we will pass as context to the OpenAI GPT.”article, stated

privacy-preserving-processing (data-access)

Document-level security filters retrieved context by the user's role before it is sent to OpenAI.

“Role-Based Access Control: A single user experience across roles restricts specific documents or sources based on the allowed level of access.”article, stated
“Depending on the Elastic Support Assistant user, we could retrieve documents appropriate for them to use as part of the context sent to OpenAI.”article, stated

batch-offline-processing (data-enrichment)

Elastic backfilled missing metadata across the knowledge library with Cloud Run jobs and controlled concurrency.

“we needed an automated process to generate these.”article, stated
“Cloud Run allows us to control the number of concurrent workers so that we don't use all of the allocated threads to our LLM instance.”article, stated

data-quality-loop (retrieval-quality)

Elastic analyzed user trends and search gaps to decide when to add new sources and enrich existing data.

“Even at the scale of hundreds of thousands of documents, we still find gaps in our documented knowledge.”article, stated
“By analyzing our user trends we are able to determine when to add new types of sources and better enrich our existing data”article, stated

Tradeoffs

Use RAG instead of fine-tuning

Chose retrieval over Elastic knowledge sources over fine-tuning a custom Support Assistant model.

Rationale: RAG matched unstructured data, supported real-time updates, enabled role-based access, and reused Support Hub search infrastructure.

“Easier with unstructured data: Fine-tuning required question-answer pairing that did not match our data set”article, stated
“Less maintenance: Search on the Support Hub and the Support Assistant share much of the same underlying infrastructure.”article, stated

Use Cloud Run crawler jobs

Chose scheduled Cloud Run jobs with Crawlee over Cloud Tasks or PubSub orchestration for this ingestion stage.

Rationale: Cloud Run jobs supported 24-hour timeouts, scheduling, and parallel category crawls that matched Elastic's needs.

“We chose this because jobs can have a timeout of 24 hours and they can be scheduled without the use of Cloud Tasks or PubSub.”article, stated
“Our needs resulted in a total of four jobs running in parallel”article, stated

Use generated summaries and questions for retrieval metadata

Chose OpenAI GPT-3.5 Turbo summaries/questions over first-280-character summaries.

Rationale: The heuristic was simpler but damaged search relevance; generated summaries improved semantic search at the required scale.

“The simplest approach was to take the first 280 characters of each document and use that as the summary.”article, stated
“One of our team’s engineers had the idea to instead use AI to do this.”article, stated

Backfill current product docs first

Chose controlled Cloud Run concurrency and weeks-long backfill over fully saturating the LLM instance for immediate backfill.

Rationale: Elastic avoided starving the Support Assistant while enriching a large corpus.

“Doing so would result in a timeout for any users of the Support Assistant”article, stated
“we elected to backfill the existing knowledge library over a period of weeks -- starting with the most current product docs.”article, stated

Gotchas (what bit them)

Large context harmed answer accuracy.

Root cause: The LLM could miss key sentences when Elastic passed larger passages rather than precise context.

Resolution: Elastic tuned retrieval around concise, relevant passages and expanded hybrid search quality.

“We initially passed larger text passages as context to the user question. This decreased the accuracy of the results”article, stated
“This transitioned search to become a problem of both finding the right documents and how these aligned with user questions.”article, stated

Crawler body extraction could pollute retrieval with filler text.

Root cause: Elastic's sources had varied document structures and irrelevant page text could become searchable.

Resolution: They created request handlers per document type to parse the relevant body CSS.

“Since the structure of the documents we crawl can vary widely, we created a request handler for each document type.”article, stated
“any filler text would also be searchable and could be returned incorrectly as a result for the context we send to the LLM.”article, stated

Product documentation versions created duplication and version-specific retrieval risk.

Root cause: Users might ask about any Elastic version, while product docs duplicate unchanged pages across versions.

Resolution: Elastic captured enough versioned documentation and tuned queries to default to current docs unless specified.

“we needed to anticipate that users of the Support Assistant might ask about any version of Elastic”article, stated
“The product docs do have some duplication of content as a given page may not change across multiple product versions.”article, stated

Metadata gaps limited semantic search over ingested documents.

Root cause: Many documents lacked useful summaries even though ELSER depended on semantic fields such as title and summary.

Resolution: Elastic generated summaries and questions with GPT-3.5 Turbo and stored them in document fields.

“Semantic search could only be as effective as the quality of the document summaries.”article, stated
“3. Updates the summary and questions fields in the document.”article, stated

Evaluation

Elastic evaluated retrieval quality through its core hypothesis that concise, relevant search context should improve user sentiment and reduce irrelevant-context usage. The team compared summary strategies, monitored search relevance, tracked corpus coverage, and used generated question fields for semantic-search suggestions.

Metrics: positive user sentiment · search relevancy · document count · AI-generated summary count · average questions per document · technical support articles with human-written summaries · context response time

3 supporting quotes
“Providing more concise and relevant search results as context for the LLM will lead to stronger positive user sentiment”article, stated
“This section of the prompt outputs a summary that is as concise as possible while still maintaining accuracy.”article, stated
“We are also testing the relevancy of including the question set in our hybrid search approach for the Elastic Support Assistant”article, stated

Outcomes

The system operated over more than 300,000 indexed documents, including over 2,800 technical support articles, and produced over 128,000 AI-generated summaries with an average of eight questions per document.

3 supporting quotes
“The result of these changes resulted in an index that we could use with ELSER for semantic search”article, stated
“At the time of writing, we have vector embeddings for the more than 300,000 documents in our indices”article, stated
“over 128,000 ai-generated summaries with an average of 8 questions per document.”article, stated