Skip to content



Elasticsearch is a NoSQL Database focused on search capabilities to act as a search engine. The Shopware implementation of Elasticsearch provides an integrated way to improve the performance of product and category searches. To use Elasticsearch for your shop, take a look at our Elasticsearch guide


Elasticsearch is only used in searches that are explicitly defined. This is by default set to the ProductSearchRoute, ProductListingRoute, and ProductSuggestRoute. To use Elasticsearch on your own searches, make sure to add the Elasticsearch aware state to your criteria.


If the Elasticsearch query fails, the data is loaded using MySQL. You can disable this behavior by setting the environment variable SHOPWARE_ES_THROW_EXCEPTION=1

$criteria = new \Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria();
$context = \Shopware\Core\Framework\Context::createDefaultContext();
// Enables Elasticsearch for this search

$repository->search($criteria, $context);


To provide Elasticsearch for an entity, a corresponding ElasticsearchDefinition needs to be added. Shopware has a definition for the product entity called ProductElasticsearchDefinition. This definition defines the fields provided to Elasticsearch and how they are aggregated.


The ElasticsearchEntitySearcher decorates the EntitySearcher to map the entity search to the Elasticsearch structure. The ElasticsearchEntitySearcher returns an IdSearchResult hydrated by the ElasticsearchEntitySearchHydrator as the EntitySearcher does, and this result is used to read the found ids from the database.


The ElasticsearchEntityAggregator does the same as the ElasticsearchEntitySearcher for aggregations.


The CriteriaParser parses the criteria to an Elasticsearch specific notation.


The product search has a special ProductSearchBuilder in the core, and so has the Elasticsearch extension, a corresponding extension for the ProductSearchBuilder. This extension matches the queries of the core ProductSearchBuilder to the Elasticsearch notation.


The ProductUpdater listens to the ProductIndexerEvent and triggers the ElasticsearchIndexer on changes to a ProductEntity.



The command es:index:cleanup deletes outdated Elasticsearch indexes. The parameter -f will skip the confirmation.


The command es:create:alias refreshes the current Elasticsearch index and sets the alias to the index name without the timestamp (which will make this index the active index). This will happen automatically when a new index is published, so this command can force the alias creation for testing purposes or if something goes wrong.


The command es:index re-indexes all configured entities to Elasticsearch.


The es:reset command resets all active indices with their respective prefix (SHOPWARE_ES_INDEX_PREFIX) in the .env file and clears the queue. This command should only be used if an index is corrupted or needs to be set up from scratch. If multiple Shopware instances are accessing the same Elasticsearch Host, you should consider changing the prefix.


The command es:status returns the status of all current Elasticsearch indices.


The command es:test:analyzer runs an Elasticsearch analyzer on your indices. For more details on Elasticsearch analyzers, take a look at this external link.

Customize the Elasticsearch integration

To customize the Elasticsearch integration or add your own fields and entities, refer to the Elasticsearch extension guide