> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xano.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Elasticsearch

## <Icon icon="https://mintcdn.com/xano-997cb9ee/aZQYcxhIvSDTNEim/images/icons/xs_temp.svg?fit=max&auto=format&n=aZQYcxhIvSDTNEim&q=85&s=6e05b86a660544b2d6040353bd8faac8" size={46} width="371" height="137" data-path="images/icons/xs_temp.svg" /> Elasticsearch: Request

```javascript theme={null}
cloud.elasticsearch.request {
  auth_type = "API Key"
  key_id = ""
  access_key = ""
  region = ""
  method = "POST"
  url = ""
  query = ""
} as x1
```

| Parameter   | Purpose                    | Example                                           |
| ----------- | -------------------------- | ------------------------------------------------- |
| auth\_type  | Authentication method      | `"API Key"`, `"Basic"`                            |
| key\_id     | Elasticsearch API key ID   | `"VuaCfGcBCdbkQm-e5aOx"`                          |
| access\_key | Elasticsearch API key      | `"ui2lp2axTNmsyakw9tvNnw"`                        |
| region      | Elasticsearch region       | `"us-east-1"`, `"eu-west-1"`                      |
| method      | HTTP method for request    | `"GET"`, `"POST"`, `"PUT"`, `"DELETE"`            |
| url         | Elasticsearch endpoint URL | `"https://search-domain.region.es.amazonaws.com"` |
| query       | Query body                 | `{query: {match_all: {}}}`                        |
| as          | Alias for response         | `x1`, `search_response`                           |

<Accordion title="Example">
  ```javascript theme={null}
  cloud.elasticsearch.request {
    auth_type = "API Key"
    key_id = $env.ES_KEY_ID
    access_key = $env.ES_ACCESS_KEY
    region = "us-west-2"
    method = "POST"
    url = "https://my-domain.es.amazonaws.com/products/_search"
    query = {
      query: {
        match: {
          name: "search term"
        }
      }
    }
  } as search_results
  ```

  * Makes direct requests to Elasticsearch
  * Supports all Elasticsearch APIs
  * Flexible query construction
  * Returns raw Elasticsearch response
</Accordion>

## <Icon icon="https://mintcdn.com/xano-997cb9ee/aZQYcxhIvSDTNEim/images/icons/xs_temp.svg?fit=max&auto=format&n=aZQYcxhIvSDTNEim&q=85&s=6e05b86a660544b2d6040353bd8faac8" size={46} width="371" height="137" data-path="images/icons/xs_temp.svg" /> Elasticsearch: Document

```javascript theme={null}
cloud.elasticsearch.document {
  auth_type = "API Key"
  key_id = ""
  access_key = ""
  region = ""
  method = "GET"
  index = ""
  doc_id = ""
  doc =
} as x2
```

| Parameter   | Purpose                  | Example                                |
| ----------- | ------------------------ | -------------------------------------- |
| auth\_type  | Authentication method    | `"API Key"`, `"Basic"`                 |
| key\_id     | Elasticsearch API key ID | `"VuaCfGcBCdbkQm-e5aOx"`               |
| access\_key | Elasticsearch API key    | `"ui2lp2axTNmsyakw9tvNnw"`             |
| region      | Elasticsearch region     | `"us-east-1"`                          |
| method      | CRUD operation type      | `"GET"`, `"POST"`, `"PUT"`, `"DELETE"` |
| index       | Index name               | `"products"`, `"users"`                |
| doc\_id     | Document identifier      | `"123"`, `$item.id`                    |
| doc         | Document data            | `{title: "Product", price: 99.99}`     |
| as          | Alias for response       | `x2`, `document_result`                |

<Accordion title="Example">
  ```javascript theme={null}
  cloud.elasticsearch.document {
    auth_type = "API Key"
    key_id = $env.ES_KEY_ID
    access_key = $env.ES_ACCESS_KEY
    region = "us-west-2"
    method = "PUT"
    index = "products"
    doc_id = "prod_123"
    doc = {
      name: "Sample Product",
      price: 29.99,
      category: "electronics"
    }
  } as document_response
  ```

  * Performs CRUD operations on documents
  * Supports create, read, update, delete
  * Works with specific document IDs
  * Returns operation result
</Accordion>

## <Icon icon="https://mintcdn.com/xano-997cb9ee/aZQYcxhIvSDTNEim/images/icons/xs_temp.svg?fit=max&auto=format&n=aZQYcxhIvSDTNEim&q=85&s=6e05b86a660544b2d6040353bd8faac8" size={46} width="371" height="137" data-path="images/icons/xs_temp.svg" /> Elasticsearch: Search Query

```javascript theme={null}
cloud.elasticsearch.query {
  auth_type = "API Key"
  key_id = ""
  access_key = ""
  region = ""
  index = ""
  payload =
  expression = []
  size = 0
  from = 0
  sort = []
  included_fields = []
  return_type = "search"
} as x3
```

| Parameter        | Purpose                  | Example                     |
| ---------------- | ------------------------ | --------------------------- |
| auth\_type       | Authentication method    | `"API Key"`, `"Basic"`      |
| key\_id          | Elasticsearch API key ID | `"VuaCfGcBCdbkQm-e5aOx"`    |
| access\_key      | Elasticsearch API key    | `"ui2lp2axTNmsyakw9tvNnw"`  |
| region           | Elasticsearch region     | `"us-east-1"`               |
| index            | Index to query           | `"products"`                |
| payload          | Query payload            | `{match: {field: "value"}}` |
| expression       | Query expressions        | `["term1", "term2"]`        |
| size             | Results per page         | `10`, `50`                  |
| from             | Starting position        | `0`, `50`                   |
| sort             | Sort criteria            | `[{field: "asc"}]`          |
| included\_fields | Fields to return         | `["name", "price"]`         |
| return\_type     | Response format          | `"search"`, `"count"`       |
| as               | Alias for results        | `x3`, `query_results`       |

<Accordion title="Example">
  ```javascript theme={null}
  cloud.elasticsearch.query {
    auth_type = "API Key"
    key_id = $env.ES_KEY_ID
    access_key = $env.ES_ACCESS_KEY
    region = "us-west-2"
    index = "products"
    payload = {
      match: {
        category: "electronics"
      }
    }
    size = 20
    from = 0
    sort = [{price: "desc"}]
    included_fields = ["name", "price", "category"]
    return_type = "search"
  } as search_results
  ```

  * Performs structured queries
  * Supports pagination
  * Configurable field selection
  * Flexible sorting options
  * Multiple return type formats
</Accordion>
