PHPackages                             acseo/sylius-typesense - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. acseo/sylius-typesense

ActiveSylius-plugin[Search &amp; Filtering](/categories/search)

acseo/sylius-typesense
======================

Sylius Typesense is a plugin for integrating Typesense, a fast and powerful search engine, with Sylius, an open-source e-commerce platform. This plugin boosts your Sylius store’s search capabilities by leveraging Typesense’s advanced search features, providing fast, relevant search results.

v1(1y ago)1855—0%1MITPHPPHP ^8.2

Since Jan 13Pushed 5mo ago4 watchersCompare

[ Source](https://github.com/acseo/SyliusTypesensePlugin)[ Packagist](https://packagist.org/packages/acseo/sylius-typesense)[ RSS](/packages/acseo-sylius-typesense/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (10)Versions (2)Used By (0)

 [ ACSEO ](https://www.acseo.fr)

Sylius Typesense
 [ ![](https://camo.githubusercontent.com/4a0f5a95a2a00e4a264bf0833f94dc74e27f08f27e74893988d81ed488ef1e9c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616373656f2f73796c6975732d7479706573656e73652e737667) ](https://packagist.org/packages/acseo/sylius-typesense "License") [ ![](https://camo.githubusercontent.com/0ecb1a7811daf9e58f5a7709e8fa6efafd6e30fd4f9c7e94d0eaa24619bcaa7e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616373656f2f73796c6975732d7479706573656e73652e737667) ](https://packagist.org/packages/acseo/sylius-typesense "Version")
====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#sylius-typesense--------------------------------)

[![](capture.gif)](capture.gif)

Introduction
------------

[](#introduction)

**Sylius Typesense** is a plugin for integrating [Typesense](https://typesense.org/), a fast and powerful search engine, with [Sylius](https://sylius.com/), an open-source e-commerce platform. This plugin boosts your Sylius store’s search capabilities by leveraging Typesense’s advanced search features, providing fast, relevant search results.

Features
--------

[](#features)

- Seamless integration with Sylius.
- Automatic indexing of product data.
- Support for a variety of field types (e.g., primary, collection, object).
- Easy-to-use console commands for creating and importing collections.

Installation
------------

[](#installation)

Follow these steps to integrate **Sylius Typesense** into your project:

### Step 1: Install the Package

[](#step-1-install-the-package)

Install the **Sylius Typesense** plugin using Composer. Run the following command in your terminal:

```
$ composer require acseo/sylius-typesense
```

### Step 2: Register the Plugin

[](#step-2-register-the-plugin)

Once the package is installed, you need to register the plugin in your Symfony application. Open the config/bundles.php file and add the following lines:

```
return [
    ACSEO\TypesenseBundle\ACSEOTypesenseBundle::class => ['all' => true],
    ACSEO\SyliusTypesense\ACSEOSyliusTypesense::class => ['all' => true],
];
```

### Step 3: Import Required Configuration

[](#step-3-import-required-configuration)

Next, import the configuration by adding the service definitions to your config/packages/\_sylius.yaml file:

```
# config/packages/_sylius.yaml
imports:
    - { resource: "@ACSEOSyliusTypesense/Resources/config/services.yaml" }
```

### Step 4: Import Routing Configuration

[](#step-4-import-routing-configuration)

To make the routes available, you need to import the routing configuration. Add the following lines to your config/routes.yaml file:

```
# config/routes.yaml
sylius_typesense:
    resource: "@ACSEOSyliusTypesense/Resources/config/routes.yaml"
```

### Step 5: Set Up Typesense with Docker

[](#step-5-set-up-typesense-with-docker)

To run Typesense locally, you can use Docker. Add the following service definition to your docker-compose.yaml file: Add to docker-compose.yaml

```
services:
    typesense:
        image: typesense/typesense:27.1
        restart: on-failure
        ports:
            - "8108:8108"
        volumes:
            - ./typesense-data:/data
        command: '--data-dir /data --api-key=xyz --enable-cors'
```

Start the services by running:

```
$ make down up
```

Configuration
-------------

[](#configuration)

### Step 1: Configure Environment Variables

[](#step-1-configure-environment-variables)

Add the following configuration to your .env file to set up the Typesense URL and API key:

```
TYPESENSE_URL=http://localhost:8108
TYPESENSE_KEY=123
PRODUCT_SEARCH_LIMIT=9
```

### Step 2: Plugin Configuration

[](#step-2-plugin-configuration)

Next, add the following configuration to your **config/packages/acseo\_typesense.yaml** file:

```
acseo_typesense:
    typesense:
        url: 'http://localhost:8108'
        key: 'xyz'
        collection_prefix: 'test_'
    collections:
        products:
            entity: 'App\Entity\Product\Product'
            fields:
                id:
                    name: id
                    type: primary
                sortable_id:
                    entity_attribute: id
                    name: sortable_id
                    type: int32
                code:
                    name: code
                    type: string
                    infix: true
                translations:
                    name: translations
                    type: collection
                    infix: true
                taxons:
                    name: taxons
                    type: collection
                    infix: true
                embedding:
                    name: embedding
                    type: float[]
                    embed:
                        from:
                            - translations
                            - taxons
                            - code
                        model_config:
                            model_name: ts/e5-small

            default_sorting_field: sortable_id
            symbols_to_index: [ '+' ]
```

You can use various field types supported by Typesense such as string, int32, float, and others. Types such as primary, collection, and object are also supported.

### Step 3: Modify the ProductTranslation Entity

[](#step-3-modify-the-producttranslation-entity)

To ensure compatibility with the Typesense plugin, you need to extend the ProductTranslation entity from **ACSEO\\SyliusTypesense\\Entity\\Product\\ProductTranslation**. Modify the ProductTranslation class in your App\\Entity\\Product namespace like so:

```
