---
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/4493/api/doc/elasticsearch/v8/operation/operation-search-application-render-query
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-search-application-render-query
products:
  - Elasticsearch
---

# Render a search application query

Availability: Preview since 8.9

## Paths

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

#### Path parameters

- `name` (string) — required
  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.

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/guide/en/elasticsearch/reference/current/token-authentication-services.html)

## 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
}
```

