# Using OpenSearch

{% hint style="info" %}
Available since `magento-scripts` 2.3.1
{% endhint %}

{% hint style="info" %}
From Magento 2.4.8 CMA will use OpenSearch as the default search engine.
{% endhint %}

## 1. Create new CMA app

```bash
npx create-magento-app@latest magento-with-opensearch
```

## 2. Set searchengine to "opensearch" in the configuration section of the config file

{% code title="cma.js" %}

```javascript
module.exports = {
    // ...other configurations
    configuration: {
        searchengine: 'opensearch' // <- set this
    }
};
```

{% endcode %}

### 2.1 Configure OpenSearch (optional)

```javascript
module.exports = {
    // ...other configurations
    configuration: {
        searchengine: 'opensearch',
        opensearch: {
            // change opensearch image here
            image: 'opensearchproject/opensearch:2.13.0',
            env: {
                // additional environment variables for container
                OPENSEARCH_JAVA_OPTS: '-Xms2048m -Xmx4096m'
            }
        }
    }
};
```

## 3. Run the application

You need to apply changes by running the [start](https://docs.create-magento-app.com/getting-started/available-commands/start) command **without** [**-s option**](https://docs.create-magento-app.com/getting-started/available-commands/start#s-skip-setup).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.create-magento-app.com/usage-guide/opensearch.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
