PReFoRCE-ES: Natural Language to Elasticsearch: An Agent Specialized for ES Query Generation in a Complex Business Context
2026 (English)Independent thesis Basic level (degree of Bachelor), 10 credits / 15 HE credits
Student thesisAlternative title
PReFoRCE-ES: Naturligt språk till Elasticsearch : En agent specialiserad för Query-generering i ett komplext affärskontext (Swedish)
Abstract [en]
Enabling non-technical users to query large-scale databases using natural language is a growing challenge in the field of data analysis. This study addresses the problem of generating correctly executable code for the Elasticsearch database, where standard language models often fail due to complex data structures. The proposed solution is PReFoRCE-ES, an iterative agentic architecture developed using LangChain4j which is a Java framework. This is an adapted version of ReFoRCE for non-relational databases that use context compression, self-refinement and consensus enforcement to validate generated queries prior to execution. The Agent was evaluated on a dataset within the telecommunications domain and benchmarked against a baseline GPT-4o. Results demonstrate that the agent outperforms the baseline on complex reasoning tasks, achieving an Execution Accuracy of 52.5% on reasoning queries and 80% on standard retrieval tasks, compared to the baseline’s 0% .The study concludes that agentic workflows are necessary for ensuring reliability in complex logical operations, though this comes at the expense of increased latency.
Place, publisher, year, edition, pages
2026.
Series
TRITA-CBH-GRU ; 2026:027
Keywords [en]
Elasticsearch, Large Language Models, Generative AI, Agentic workflows, RAG, LangChain4j, Prompt-technique, BGE-M3
Keywords [sv]
Elasticsearch, Stora språkmodeller, Generativ AI, Agent-system, RAG, LangChain4j, Prompt-teknik, BGE-M3
National Category
Artificial Intelligence
Identifiers
URN: urn:nbn:se:kth:diva-376823OAI: oai:DiVA.org:kth-376823DiVA, id: diva2:2039530
External cooperation
Giesecke+Devrient
Subject / course
Computer Technology, Program- and System Development
Educational program
Bachelor of Science in Engineering - Engineering and Economics
Supervisors
Examiners
2026-02-202026-02-172026-02-20Bibliographically approved