# Looking for Open-Source Models for Text-to-DSL Query Generation in OpenSearch

**URL:** <https://forum.opensearch.org/t/looking-for-open-source-models-for-text-to-dsl-query-generation-in-opensearch/26334>\
**Category:** OpenSearch\
**Created:** [August 12, 2025, 4:06pm UTC](https://forum.opensearch.org/t/looking-for-open-source-models-for-text-to-dsl-query-generation-in-opensearch/26334 "2025-08-12T16:06:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arun](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/arun/32/8227_2.png) [@Arun](https://forum.opensearch.org/u/Arun)\
**Post date:** [August 12, 2025, 4:06pm UTC](https://forum.opensearch.org/t/looking-for-open-source-models-for-text-to-dsl-query-generation-in-opensearch/26334/1 "2025-08-12T16:06:47Z")

</div>

I’m building a system where users enter a natural language query, and an LLM converts it into an **OpenSearch DSL** query. My workflow looks like this:

1. Provide the model with an OpenSearch index schema and 1–2 sample documents.

2. Pass the user’s natural language query.

3. Model generates the corresponding DSL.

4. Validate the DSL in OpenSearch.

5. Store valid query–DSL pairs for future fine-tuning.

I’m specifically looking for **open-source models** that:

- Handle structured JSON output well (e.g., match, bool, filter, sort, aggregations).

- Are easy to fine-tune with domain-specific DSL patterns.

- Can run locally for testing but also scale in production.

- Work well with schema + sample doc prompts.

If you’ve successfully fine-tuned any open-source model for OpenSearch DSL generation

---

<div class="post-metadata">

**Author:** ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/pablo/32/10363_2.png) [@pablo](https://forum.opensearch.org/u/pablo)\
**Post date:** [October 22, 2025, 2:57pm UTC](https://forum.opensearch.org/t/looking-for-open-source-models-for-text-to-dsl-query-generation-in-opensearch/26334/2 "2025-10-22T14:57:11Z")

</div>

@Arun I think this could fit your needs.

> **[Query Planning tool](https://docs.opensearch.org/latest/ml-commons-plugin/agents-tools/tools/query-planning-tool/)**
>
> The QueryPlanningTool generates an OpenSearch query domain-specific language (DSL) query from a natural language question. It is a core component of agentic...

> [@The DSL query is being generated in a different format while executing the agent](https://forum.opensearch.org/t/the-dsl-query-is-being-generated-in-a-different-format-while-executing-the-agent/27312/4):
>
> @arnabmca2006 I think it might be what you’re looking for. OpenAI: "response\_filter": "$.choices[0].message.content" Anthropic Claude (Amazon Bedrock Converse API): "response\_filter": "$.output.message.content[0].text" I used that with my agent POST /\_plugins/\_ml/agents/\_register { "name": "Agentic Search with Claude 4", "type": "flow", "description": "A test agent for query planning.", "tools": [ { "type": "QueryPlanningTool", "description": "A general tool to answe…

---

<div class="post-metadata">

**Author:** ![jaspher](https://avatars.discourse-cdn.com/v4/letter/j/6f9a4e/32.png) [@jaspher](https://forum.opensearch.org/u/jaspher)\
**Post date:** [October 31, 2025, 5:32am UTC](https://forum.opensearch.org/t/looking-for-open-source-models-for-text-to-dsl-query-generation-in-opensearch/26334/3 "2025-10-31T05:32:47Z")

</div>

I’m building a similar setup where user prompts should be translated into OpenSearch DSL automatically.

Could anyone share which model(s) worked best for you — especially smaller or offline models
