← Blog
Jul 15, 2024

ElastranAI: Building an Elastic-Powered AI Assistant

The development story of ElastranAI - an AI assistant with native Elasticsearch integration for semantic search and intelligent document retrieval.

ElastranAIelasticsearchAIsemantic-searchdevelopment

What happens when you combine conversational AI with enterprise-grade search?

ElastranAI was our answer—an AI assistant that doesn’t just respond to queries but searches, retrieves, and synthesizes information from massive document collections.

The Origin

Traditional AI assistants have a context problem. They’re limited to:

But organizations have terabytes of institutional knowledge. ElastranAI connects AI to that knowledge.

Architecture

ElastranAI Architecture
├── Frontend (Next.js)
│   ├── Conversational interface
│   ├── Document viewer
│   └── Search visualization
├── Backend (FastAPI)
│   ├── Query processing
│   ├── AI orchestration
│   └── Response synthesis
├── Elasticsearch
│   ├── Document indexing
│   ├── Semantic search
│   └── Result ranking
└── AI Layer
    ├── Query understanding
    ├── Document analysis
    └── Response generation

Why Elasticsearch?

Elasticsearch provides:

Why Not Just Use RAG?

Standard RAG (Retrieval-Augmented Generation) has limitations:

ElastranAI uses a hybrid approach:

  1. Parse and understand the query
  2. Multi-strategy search (keyword + semantic + filters)
  3. Intelligent result re-ranking
  4. Contextual response synthesis

Key Features

Semantic Query Understanding

Before searching, we understand what you’re actually asking:

async def understand_query(query: str) -> QueryIntent:
    """
    Classify query intent and extract parameters:
    - Is this a factual question or exploratory?
    - What entities are mentioned?
    - What time range is relevant?
    - What document types should be prioritized?
    """
    intent = await classify_intent(query)
    entities = extract_entities(query)
    filters = infer_filters(intent, entities)
    
    return QueryIntent(
        type=intent,
        entities=entities,
        filters=filters,
        search_strategy=select_strategy(intent)
    )

Combine multiple search strategies:

def hybrid_search(query: str, intent: QueryIntent) -> SearchResults:
    # Strategy 1: Keyword search with BM25
    keyword_results = elastic.search(
        query={"match": {"content": query}},
        size=20
    )
    
    # Strategy 2: Semantic search with vectors
    embedding = generate_embedding(query)
    vector_results = elastic.search(
        knn={"field": "embedding", "query_vector": embedding},
        size=20
    )
    
    # Strategy 3: Filtered search based on entities
    filtered_results = elastic.search(
        query={"bool": {"must": intent.filters}},
        size=20
    )
    
    # Fusion: Combine and re-rank
    return fuse_and_rank(keyword_results, vector_results, filtered_results)

Contextual Response Synthesis

Don’t just return documents—synthesize answers:

async def synthesize_response(query: str, documents: list) -> Response:
    """
    Generate response that:
    - Directly answers the question
    - Cites sources appropriately
    - Acknowledges uncertainty when present
    - Suggests follow-up questions
    """
    context = prepare_context(documents)
    
    response = await llm.generate(
        system="You are a research assistant with access to documents...",
        user=f"Query: {query}\n\nRelevant documents:\n{context}"
    )
    
    return Response(
        answer=response.text,
        sources=extract_citations(response, documents),
        confidence=calculate_confidence(response, documents),
        follow_ups=suggest_follow_ups(query, documents)
    )

Performance Results

Search Latency

Operation Latency
Query parsing 50ms
Keyword search 30ms
Vector search 80ms
Result fusion 20ms
Total search 180ms avg

Quality Metrics

Metric Score
Answer accuracy 91%
Source relevance 88%
Response helpfulness 4.3/5.0

Scale Testing

Successfully tested with:

Real-World Use Cases

Internal Knowledge Base

Scenario: Engineering team with 10,000+ documents Problem: Finding relevant information takes hours Solution: Index all docs in ElastranAI

Result:

Customer Support

Scenario: Support team handling technical questions Problem: Agents spend 40% of time searching for answers Solution: ElastranAI connected to product documentation

Result:

Scenario: Law firm with case file archive Problem: Finding precedent takes days Solution: Semantic search across case history

Result:

Lessons Learned

1. Query Understanding Is Critical

Without understanding what the user actually wants, even the best search engine returns irrelevant results.

2. Hybrid Search Beats Pure Approaches

Neither keyword-only nor vector-only search is sufficient. The fusion approach consistently outperforms.

3. Citations Build Trust

Users trust AI responses more when sources are visible. Always show your work.

4. Latency Matters More Than You Think

Every 100ms of search latency reduces user satisfaction. We optimized aggressively.

What’s Next

Current roadmap:


ElastranAI represents our approach to knowledge-augmented AI. For related technologies, see MCP orchestration and Universal Knowledge Synthesizer.

All posts Work with me