Meilisearch is an open-source search engine written in Rust, designed to create lightning-fast and hyper-relevant search experiences out of the box.
composer require setono/sylius-meilisearch-plugin
# config/packages/setono_sylius_meilisearch.yaml
setono_sylius_meilisearch:
indexes:
products:
document: 'Setono\SyliusMeilisearchPlugin\Document\Product'
entities: [ 'App\Entity\Product\Product' ]
search:
index: products
In your .env.local
add your parameters:
###> setono/sylius-meilisearch-plugin ###
MEILISEARCH_HOST=http://localhost:7700
MEILISEARCH_MASTER_KEY=YOUR_MASTER_KEY
###< setono/sylius-meilisearch-plugin ###
# config/routes/setono_sylius_meilisearch.yaml
setono_sylius_meilisearch:
resource: "@SetonoSyliusMeilisearchPlugin/Resources/config/routes.yaml"
or if your app doesn't use locales:
# config/routes/setono_sylius_meilisearch.yaml
setono_sylius_meilisearch:
resource: "@SetonoSyliusMeilisearchPlugin/Resources/config/routes_no_locale.yaml"
The entities you've configured for indexing has to implement the Setono\SyliusMeilisearchPlugin\Model\IndexableInterface
.
In a typical Sylius application for the Product
entity it could look like this:
<?php
declare(strict_types=1);
namespace App\Entity\Product;
use Doctrine\ORM\Mapping as ORM;
use Setono\SyliusMeilisearchPlugin\Model\IndexableAwareTrait;
use Setono\SyliusMeilisearchPlugin\Model\IndexableInterface;
use Sylius\Component\Core\Model\Product as BaseProduct;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_product")
*/
class Product extends BaseProduct implements IndexableInterface
{
public function getDocumentIdentifier(): ?string
{
return (string) $this->getId();
}
}