Skip to content

Latest commit

 

History

History
163 lines (123 loc) · 4.59 KB

README.md

File metadata and controls

163 lines (123 loc) · 4.59 KB
Schranz Search Logo with a Seal on it with a magnifying glass

Schranz Search SEAL
Symfony Integration



Integration of the Schranz Search — Search Engine Abstraction Layer (SEAL) into Symfony.

Note: This is part of the schranz-search/schranz-search project create issues in the main repository.

Note: This project is heavily under development and any feedback is greatly appreciated.

Installation

Use composer for install the package:

composer require schranz-search/symfony-bundle

Also install one of the listed adapters.

List of adapters

The following adapters are available:

Additional Wrapper adapters:

Creating your own adapter? Add the seal-php-adapter Topic to your Github Repository.

Configuration

The following code shows how to configure the package:

# config/packages/schranz_search.yaml

schranz_search:
    schemas:
        app:
            dir: '%kernel.project_dir%/config/schemas'
            # engine: 'default'
    engines:
        default:
            adapter: '%env(ENGINE_URL)%'

A more complex configuration can be here found:

# config/packages/schranz_search.yaml

schranz_search:
    schemas:
        app:
            dir: '%kernel.project_dir%/config/schemas/app'
        other:
            dir: '%kernel.project_dir%/config/schemas/other'
            engine: algolia
    engines:
        algolia:
            adapter: 'algolia://%env(ALGOLIA_APPLICATION_ID)%:%env(ALGOLIA_ADMIN_API_KEY)%'
        elasticsearch:
            adapter: 'elasticsearch://127.0.0.1:9200'
        meilisearch:
            adapter: 'meilisearch://127.0.0.1:7700'
        memory:
            adapter: 'memory://'
        opensearch:
            adapter: 'opensearch://127.0.0.1:9200'
        redisearch:
            adapter: 'redis://[email protected]:6379'
        solr:
            adapter: 'solr://127.0.0.1:8983'
        typesense:
            adapter: 'typesense://[email protected]:8108'

        # ...
        multi:
            adapter: 'multi://elasticsearch?adapters[]=opensearch'
        read-write:
            adapter: 'read-write://elasticsearch?write=multi'
    index_name_prefix: ''

Usage

The default engine is available as Engine:

class Some {
    public function __construct(
        private readonly \Schranz\Search\SEAL\EngineInterface $engine,
    ) {
    }
}

A specific engine is available under the config key suffix with Engine:

class Some {
    public function __construct(
        private readonly \Schranz\Search\SEAL\EngineInterface $algoliaEngine,
    ) {
    }
}

Multiple engines can be accessed via the EngineRegistry:

class Some {
    private Engine $engine;

    public function __construct(
        private readonly \Schranz\Search\SEAL\EngineRegistry $engineRegistry,
    ) {
        $this->engine = $this->engineRegistry->get('algolia');
    }
}

How to create a Schema file and use your Engine can be found SEAL Documentation.

Commands

The bundle provides the following commands:

Create configured indexes

bin/console schranz:search:index-create --help

Drop configured indexes

bin/console schranz:search:index-drop --help

Authors