bitbag / elasticsearch-plugin
BitBag Elasticsearch plugin for Sylius.
Installs: 397 204
Dependents: 1
Suggesters: 0
Security: 0
Stars: 132
Watchers: 15
Forks: 95
Open Issues: 8
Type:sylius-plugin
Requires
- php: ^8.2 || ^8.3
- ext-json: *
- friendsofsymfony/elastica-bundle: ^6.0
- sylius/sylius: ^2.0
- symfony/property-access: ^6.4 || ^7.1
- symfony/webpack-encore-bundle: ^2.2
Requires (Dev)
- behat/behat: ^3.16
- behat/mink-selenium2-driver: ~1.6.0
- bitbag/coding-standard: ^v2.0
- dbrekelmans/bdi: ^1.1
- dmore/behat-chrome-extension: ^1.3
- dmore/chrome-mink-driver: ^2.7
- friends-of-behat/mink: ^1.11
- friends-of-behat/mink-browserkit-driver: ^1.4
- friends-of-behat/mink-debug-extension: ^2.0.0
- friends-of-behat/mink-extension: ^2.4
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.0
- friends-of-behat/symfony-extension: ^2.1
- friends-of-behat/variadic-extension: ^1.3
- lchrusciel/api-test-case: ^5.2
- phpspec/phpspec: ^7.2
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.8.1
- phpstan/phpstan-doctrine: 1.3.69
- phpstan/phpstan-strict-rules: ^1.3.0
- phpstan/phpstan-webmozart-assert: ^1.2.0
- phpunit/phpunit: ^10.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- robertfausk/behat-panther-extension: ^1.1
- sylius-labs/coding-standard: ^4.2
- sylius-labs/suite-tags-extension: ^0.2
- symfony/browser-kit: ^6.4 || ^7.1
- symfony/debug-bundle: ^6.4 || ^7.1
- symfony/dotenv: ^6.4 || ^7.1
- symfony/intl: ^6.4 || ^7.1
- symfony/web-profiler-bundle: ^6.4 || ^7.1
- v5.2.1
- v5.2.0
- v5.1.0
- v5.0.0
- v4.2.2
- v4.2.1
- v4.2
- v4.1.1
- v4.1.0
- v4.0.2
- v4.0.1
- v4.0.0
- v3.3.2
- v3.3.1
- v3.3.0
- v3.2.4
- v3.2.3
- v3.2.2
- v3.2.1
- v3.2.0
- v3.1.1
- v3.1.0
- v3.0.0
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.1
- v2.0.0-beta1
- 1.x-dev
- dev-master / 1.13.x-dev
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.4
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.6
- v1.5.5
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.3
- v1.4.2
- v1.4.1
- v1.2.0
- v1.1.0
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v1.0.0-beta.4
- v1.0.0-beta.3
- v1.0.0-beta.2
- v1.0.0-beta.1
- dev-fix/manual
- dev-feature/remove-selenium2
- dev-OP-572
- dev-bring-back-symfony-6.4-support
- dev-upgrade-to-20
- dev-upgrade-to-20-open_api_docs
- dev-feature/Sylius-2_0_upgrade_build
- dev-feature/Sylius-2_0_taxon_search
- dev-dependabot/composer/tests/Application/symfony/http-kernel-6.0.20
- dev-dependabot/composer/tests/Application/symfony/http-foundation-6.4.16
- dev-api-facets-fix
- dev-OP-546
- dev-feature/upgrade-2.0
- dev-fix/refreshing_deleted_resource
- dev-OP-505
- dev-OP-514
- dev-use_parameter_for_max_filter
- dev-op-303-api-support
- dev-fix/op-331-fix-missing-breadcrumbs
- dev-op-288-es-refactor
- dev-op-225-product-option-populate
- dev-op-277-search-facets-dto
- dev-bugfix/sylius-1.13-update
- dev-feature/sylius-1.13-update
- dev-merge_fix
- dev-fix/OP-225-not-updated-option-filters
- dev-feature/1.13
- dev-fix/doctrine
- dev-OP-180-validation-for-filter-values
- dev-feature/slack-notifications
- dev-OP-119-move-url-and-port-to-env
- dev-fix/OP-87-Fix-indexes-out-of-sync
- dev-fix/OP-57-sort-limit
- dev-fix/search
- dev-OPSRC-496/Add_bitbag_coding_standard_to_every_plugin
- dev-OPSRC-602/fix-symfony-flex
- dev-feature/webpack-implementation
- dev-Implement-Webpack-Encore
- dev-github-actions
- dev-fix/translations-search
- dev-dev
This package is auto-updated.
Last update: 2025-07-04 08:42:33 UTC
README
BitBag SyliusElasticsearchPlugin
We want to impact many unique eCommerce projects and build our brand recognition worldwide, so we are heavily involved in creating open-source solutions, especially for Sylius. We have already created over 35 extensions, which have been downloaded almost 2 million times.
You can find more information about our eCommerce services and technologies on our website: https://bitbag.io/. We have also created a unique service dedicated to creating plugins: https://bitbag.io/services/sylius-plugin-development.
Do you like our work? Would you like to join us? Check out the “Career” tab: https://bitbag.io/pl/kariera.
About Us
BitBag is a software house that implements tailor-made eCommerce platforms with the entire infrastructure—from creating eCommerce platforms to implementing PIM and CMS systems to developing custom eCommerce applications, specialist B2B solutions, and migrations from other platforms.
We actively participate in Sylius's development. We have already completed over 150 projects, cooperating with clients worldwide, including smaller enterprises and large international companies. We have completed projects for such important brands as Mytheresa, Foodspring, Planeta Huerto (Carrefour Group), Albeco, Mollie, and ArtNight.
We have a 70-person team of experts: business analysts and consultants, eCommerce developers, project managers, and QA testers.
Our services:
- B2B and B2C eCommerce platform implementations
- Multi-vendor marketplace platform implementations
- eCommerce migrations
- Sylius plugin development
- Sylius consulting
- Project maintenance and long-term support
- PIM and CMS implementations
Some numbers from BitBag regarding Sylius:
- 70 experts on board
- +150 projects delivered on top of Sylius,
- 30 countries of BitBag’s customers,
- 7 years in the Sylius ecosystem.
- +35 plugins created for Sylius
Table of Content
Overview
Working Sylius Elasticsearch integration based on FOSElasticaBundle. The main goal of this plugin is to support filtering products by options, attributes, taxons, channels and name in the front product list page. It totally replaces the default Sylius sylius_shop_product_index
route.
What is more, the plugin has a nice Sylius-oriented architecture that allows mapping resources to the Elastic document easier. It is flexible as well, so that you can customize the existing features for your specific business needs.
If you are curious about the details of this plugin, read this blog post and watch the video below.
Installation
For the full installation guide, please go here.
Requirements
This plugin requires elasticsearch server running. You can install it by following the instructions on the official website. In plugin repository there is Docker Compose file that can be used to run Elasticsearch server.
Note: This Plugin supports ElasticSearch 7.0 and above. If you're looking for ElasticSearch Plugin for older versions check SyliusElasticSearchPlugin in version 1.x.
We work on stable, supported and up-to-date versions of packages. We recommend you to do the same.
Package | Version |
---|---|
PHP | 8.2 or 8.3 |
sylius/sylius | >= 2.0 |
MySQL | >= 5.7 |
NodeJS | >= 18.x |
ElasticSearch | >= 7.x |
Usage
Scope of the search
This plugin offers a site-wide search feature and taxon search feature. It is easily extendable to add more search scopes. For example in Marketplace suite you can create Vendor specific search scope.
Searching site-wide products
There is searchbar in the header of the shop.

You can easily modify it by overriding the @BitBagSyliusElasticsearchPlugin/Shop/Layout/Header/searchForm.html.twig
and templates @BitBagSyliusElasticsearchPlugin/Shop/SearchForm/searchForm.html.twig
or disable it by setting:
sylius_twig_hooks: hooks: 'sylius_shop.base.header.content': search_form: template: "@BitBagSyliusElasticsearchPlugin/Shop/Layout/Header/searchForm.html.twig" priority: 250 enabled: false 'sylius_shop.base.header.content.search_form': content: component: 'bitbag.sylius_elasticsearch_plugin:search_form' props: template: "@BitBagSyliusElasticsearchPlugin/Shop/SearchForm/searchForm.html.twig" priority: 0 enabled: false
Searching taxon products
When you go now to the /{_locale}/taxons/{slug}
page, you should see a totally new set of filters. You should see something like this:

It is important that the routing.yml
from the plugin are loaded before sylius_shop
:
bitbag_sylius_elasticsearch_plugin: resource: "@BitBagSyliusElasticsearchPlugin/config/routing.yml" sylius_shop: resource: "@SyliusShopBundle/Resources/config/routing.yml" prefix: /{_locale} requirements: _locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$
Excluding options and attributes in the filter menu
You might not want to show some specific options or attributes in the menu. You can set specific parameters for that:
parameters: bitbag_es_excluded_facet_attributes: ['jeans_material'] bitbag_es_excluded_facet_options: ['t_shirt_size']
By default, all options and attributes filters are shown.
It is also possible to disable options and attribute filters autodiscovery by setting the following parameters:
parameters: bitbag_es_facets_auto_discover: false
Then you have to manually register your filters:
Available filters:
TaxonFacet
which allows to filter your search results by taxons using the ElasticSearchTerms
aggregation.AttributeFacet
which allows to filter your search results by product attributes values using the ElasticSearchTerms
aggregation.OptionFacet
which is the same asAttributeFacet
but for product options.PriceFacet
which allows to filter search results by price range the ElasticSearchHistogram
aggregation.
Example of manual registration of filters:
services: bitbag_sylius_elasticsearch_plugin.facet.attribute.t_shirt_brand: class: BitBag\SyliusElasticsearchPlugin\Facet\AttributeFacet arguments: - '@bitbag_sylius_elasticsearch_plugin.property_name_resolver.attribute' - '@=service("sylius.repository.product_attribute").findOneBy({"code": "t_shirt_brand"})' - '@sylius.context.locale' bitbag_sylius_elasticsearch_plugin.facet.registry: class: BitBag\SyliusElasticsearchPlugin\Facet\Registry calls: - method: addFacet arguments: - t_shirt_brand - '@bitbag_sylius_elasticsearch_plugin.facet.attribute.t_shirt_brand' - method: addFacet arguments: - price - '@bitbag_sylius_elasticsearch_plugin.facet.price' - method: addFacet arguments: - taxon - '@bitbag_sylius_elasticsearch_plugin.facet.taxon'
Reindexing
By default, current indexes listen on all Doctrine events. You can override this setting for each index by overriding index definition in your config.yml
file:
fos_elastica: indexes: bitbag_attribute_taxons: types: default: persistence: listener: insert: true update: false delete: true
Indexes with bitbag_shop_product
, bitbag_attribute_taxons
and bitbag_option_taxons
keys are available so far.
Search fuzziness
Fuzziness in Elasticsearch is a feature that allows search queries to match terms even if there are minor typos or spelling mistakes. It works by calculating the Levenshtein distance (edit distance) between the query term and indexed terms, enabling the search engine to find similar words—for example, a search for “aple” can still match “apple.” Fuzziness is commonly used in full-text search to improve result accuracy despite small user input errors.
You can set the fuzziness of the search by overriding the bitbag_sylius_elasticsearch_plugin.query_builder.contains_name
service in your service file (min. -> 0, max. -> 2)
:
<service id="bitbag_sylius_elasticsearch_plugin.query_builder.contains_name" class="BitBag\SyliusElasticsearchPlugin\QueryBuilder\ContainsNameQueryBuilder"> <argument type="service" id="sylius.context.locale" /> <argument type="service" id="bitbag_sylius_elasticsearch_plugin.search_property_name_resolver_registry" /> <argument type="string">AUTO</argument> </service>
bitbag_sylius_elasticsearch_plugin.query_builder.contains_name: class: BitBag\SyliusElasticsearchPlugin\QueryBuilder\ContainsNameQueryBuilder arguments: - '@sylius.context.locale' - '@bitbag_sylius_elasticsearch_plugin.search_property_name_resolver_registry' - 'AUTO'
Customization
Available services you can decorate and forms you can extend
$ bin/console debug:container | grep bitbag_sylius_elasticsearch_plugin
Parameters you can override in your parameters.yml(.dist) file
$ bin/console debug:container --parameters | grep bitbag
Testing
$ composer install
$ cd tests/Application
$ APP_ENV=test bin/console doctrine:database:create
$ APP_ENV=test bin/console doctrine:schema:create
// run elasticsearch
$ APP_ENV=test bin/console sylius:fixtures:load
$ APP_ENV=test bin/console fos:elastica:populate
$ APP_ENV=test symfony server:run 127.0.0.1:8080 -d
$ APP_ENV=test bin/console assets:install
$ open http://localhost:8080
$ vendor/bin/behat
$ vendor/bin/phpspec run
Functionalities
All main functionalities of the plugin are described here.
If you need some help with Sylius development, don't be hesitated to contact us directly. You can fill the form on this site or send us an e-mail at hello@bitbag.io!
Demo
We created a demo app with some useful use-cases of plugins! Visit http://demo.sylius.com/ to take a look at it.
If you need an overview of Sylius' capabilities, schedule a consultation with our expert.
Additional resources for developers
To learn more about our contribution workflow and more, we encourage you to use the following resources:
- Sylius Documentation
- Sylius Contribution Guide
- Sylius Online Course
- Sylius Elasticsearch Plugin Blog
License
This plugin's source code is completely free and released under the terms of the MIT license.
Contact and Support
This open-source plugin was developed to help the Sylius community. If you have any additional questions, would like help with installing or configuring the plugin, or need any assistance with your Sylius project - let us know! Contact us or send us an e-mail to hello@bitbag.io with your question(s).
Community
For online communication, we invite you to chat with us & other users on Sylius Slack.