Skip to content

Document Mustache template support in Search Relevance Workbench - #12810

Open
Bharathi-Kanna wants to merge 3 commits into
opensearch-project:mainfrom
Bharathi-Kanna:feature/search-relevance-mustache-templates
Open

Document Mustache template support in Search Relevance Workbench#12810
Bharathi-Kanna wants to merge 3 commits into
opensearch-project:mainfrom
Bharathi-Kanna:feature/search-relevance-mustache-templates

Conversation

@Bharathi-Kanna

Copy link
Copy Markdown

Search configurations can now use Mustache template variables ({{query_string}} and query set custom fields) in the query, in addition to the existing %SearchText% placeholder. Document the templating behavior, variable sources, automatic JSON escaping, and that Mustache partials are not supported, with an example. Also document custom fields on query set entries and how they map to template variables.

Corresponds to opensearch-project/search-relevance#342.

Search configurations can now use Mustache template variables ({{query_string}}
and query set custom fields) in the query, in addition to the existing
%SearchText% placeholder. Document the templating behavior, variable sources,
automatic JSON escaping, and that Mustache partials are not supported, with an
example. Also document custom fields on query set entries and how they map to
template variables.

Corresponds to opensearch-project/search-relevance#342.

Signed-off-by: Bharathi-Kanna <99189546+Bharathi-Kanna@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Thank you for submitting your PR. The PR states are In progress (or Draft) -> Tech review -> Doc review -> Merged.

Before you submit your PR for doc review, make sure the content is technically accurate. If you need help finding a tech reviewer, tag a maintainer.

When you're ready for doc review, tag the assignee of this PR. The doc reviewer may push edits to the PR directly or leave comments and editorial suggestions for you to address (let us know in a comment if you have a preference).

@kolchfa-aws

Copy link
Copy Markdown
Collaborator

@epugh Could you review this PR?

@kolchfa-aws

Copy link
Copy Markdown
Collaborator

@Bharathi-Kanna Thanks for the PR! What version is this PR targeting?


The following variables are available when a template is rendered:

* `{{query_string}}`: The `queryText` of the current query set entry.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it to be same as field name from query set?

Suggested change
* `{{query_string}}`: The `queryText` of the current query set entry.
* `{{queryText}}`: The `queryText` of the current query set entry.

PUT _plugins/_search_relevance/search_configurations
{
"name": "mustache_filter",
"query": "{\"query\":{\"bool\":{\"must\":[{\"match\":{\"title\":\"{{query_string}}\"}}],\"filter\":[{\"term\":{\"category\":\"{{category}}\"}}]}}}",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"query": "{\"query\":{\"bool\":{\"must\":[{\"match\":{\"title\":\"{{query_string}}\"}}],\"filter\":[{\"term\":{\"category\":\"{{category}}\"}}]}}}",
"query": "{\"query\":{\"bool\":{\"must\":[{\"match\":{\"title\":\"{{queryText}}\"}}],\"filter\":[{\"term\":{\"category\":\"{{category}}\"}}]}}}",

@heemin32

Copy link
Copy Markdown
Contributor

This doc should not be released until this PR is merged. opensearch-project/search-relevance#342

Match the query set field name (queryText) instead of {{query_string}}, per
review feedback on opensearch-project/search-relevance#342.

Signed-off-by: Bharathi-Kanna <99189546+Bharathi-Kanna@users.noreply.github.com>
@heemin32

Copy link
Copy Markdown
Contributor

@Bharathi-Kanna Thanks for the PR! What version is this PR targeting?

The PR is merged. It is targeting 3.8.

@kolchfa-aws

Copy link
Copy Markdown
Collaborator

@Bharathi-Kanna Please let me know once you address tech review comments from Heemin and you have a tech approval, and I'll review the PR from the doc side. Thanks!

@kolchfa-aws kolchfa-aws added release-notes PR: Include this PR in the automated release notes v3.8.0 and removed Awaiting response labels Jul 21, 2026
@heemin32

Copy link
Copy Markdown
Contributor

@Bharathi-Kanna Please let me know once you address tech review comments from Heemin and you have a tech approval, and I'll review the PR from the doc side. Thanks!

All my comments are addressed. Thanks.

@kolchfa-aws kolchfa-aws added Doc review PR: Doc review in progress and removed Tech review PR: Tech review in progress labels Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Doc review PR: Doc review in progress release-notes PR: Include this PR in the automated release notes v3.8.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants