---
type: api
title: Render a search application query
description: Generate an Elasticsearch query using the specified query parameters and the search template associated with the search application or a default template if none is specified.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/operation/operation-search-application-render-query
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/operation/operation-search-application-render-query
products:
  - Elasticsearch
---

# Render a search application query

Availability: 8.9+

## Paths

- `POST` `/_application/search_application/{name}/_render_query`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#bearerauth)

#### Path Parameters

- `name` (string Name)
  The name of the search application to render teh query for.

## Description

Generate an Elasticsearch query using the specified query parameters and the search template associated with the search application or a default template if none is specified.
If a parameter used in the search template is not specified in `params`, the parameter's default value will be used.
The API returns the specific Elasticsearch query that would be generated and run by calling the search application search API.

You must have `read` privileges on the backing alias of the search application.

## Request Body

`application/json`

- `params` (map string to object) — optional

## Response

`application/json`

Type: `object`

## Code Examples

#### Console

```console
POST _application/search_application/my-app/_render_query
{
  "params": {
    "query_string": "my first query",
    "text_fields": [
      {
        "name": "title",
        "boost": 5
      },
      {
        "name": "description",
        "boost": 1
      }
    ]
  }
}
```

#### JavaScript

```javascript
const response = await client.searchApplication.renderQuery({
  name: "my-app",
  params: {
    query_string: "my first query",
    text_fields: [
      {
        name: "title",
        boost: 5,
      },
      {
        name: "description",
        boost: 1,
      },
    ],
  },
});
```

#### Python

```python
resp = client.search_application.render_query(
    name="my-app",
    params={
        "query_string": "my first query",
        "text_fields": [
            {
                "name": "title",
                "boost": 5
            },
            {
                "name": "description",
                "boost": 1
            }
        ]
    },
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_application/search_application/my-app/_render_query" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "params": {
      "query_string": "my first query",
      "text_fields": [
        {
          "name": "title",
          "boost": 5
        },
        {
          "name": "description",
          "boost": 1
        }
      ]
    }
  }'
```

#### Java

```java
client.searchApplication().renderQuery(r -> r
    .name("my-app")
    .params(Map.of("text_fields", JsonData.fromJson("""
[{"name":"title","boost":5},{"name":"description","boost":1}]
"""),"query_string", JsonData.fromJson("\"my first query\"")))
);
```

#### C#

```c#
var response = await client.SearchApplication
    .RenderQueryAsync(name: "my-app", d1 => d1
        .Params(new Dictionary<string, object>()
        {
            { "query_string", "my first query" },
            { "text_fields", JsonSerializer.Deserialize<JsonElement>("""
            [
              {
                "name": "title",
                "boost": 5
              },
              {
                "name": "description",
                "boost": 1
              }
            ]
            """) }
        })
    );
```

#### PHP

```php
$resp = $client->searchApplication()->renderQuery([
    "name" => "my-app",
    "body" => [
        "params" => [
            "query_string" => "my first query",
            "text_fields" => array(
                [
                    "name" => "title",
                    "boost" => 5,
                ],
                [
                    "name" => "description",
                    "boost" => 1,
                ],
            ),
        ],
    ],
]);
```

#### Ruby

```ruby
response = client.search_application.render_query(
  name: "my-app",
  body: {
    "params": {
      "query_string": "my first query",
      "text_fields": [
        {
          "name": "title",
          "boost": 5
        },
        {
          "name": "description",
          "boost": 1
        }
      ]
    }
  }
)
```

## Response Examples

#### Search applications render query response example1

A successful response for generating a query for a search application. The `from`, `size`, and `explain` parameters were not specified in the request, so the default values specified in the search template are used.

```json
{
  "from": 0,
  "size": 10,
  "query": {
    "multi_match": {
      "query": "my first query",
      "fields": [
        "description^1.0",
        "title^5.0"
      ]
    }
  },
  "explain": false
}
```

