PHPackages                             ebrana/elasticsearch-bundle - 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. [API Development](/categories/api)
4. /
5. ebrana/elasticsearch-bundle

ActiveLibrary[API Development](/categories/api)

ebrana/elasticsearch-bundle
===========================

v1.0.0(2mo ago)04.1k—4.5%1MITPHPPHP &gt;=8.3.0

Since Mar 16Pushed 2mo ago5 watchersCompare

[ Source](https://github.com/ebrana/elasticsearch-bundle)[ Packagist](https://packagist.org/packages/ebrana/elasticsearch-bundle)[ RSS](/packages/ebrana-elasticsearch-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (5)Used By (0)

Elasticsearch Bundle
====================

[](#elasticsearch-bundle)

Elasticsearch Symfony Bundle pro balíček .

### Instalace

[](#instalace)

```
composer require ebrana/elasticsearch-bundle

```

#### Konfigurace

[](#konfigurace)

```
elasticsearch:
    profiling: true
    indexPrefix: "katalog_"
    # cache je nepovinné (adapters: https://symfony.com/doc/current/components/cache.html#available-cache-adapters)
    cache: 'cache.adapter.filesystem'
    # tato sekce může být vynechána, protože attributes je default driver
    #    driver:
    #        type: "attributes" # attributes nebo json
    mappings:
        - App\Entity\Elasticsearch\Product
    connection:
        hosts:
            - '%env(resolve:ELASTICSEARCH_URL)%'
        username: ""
        password: ""
        cloudId: ""
        retries: 10
        elasticMetaHeader: true/false
        logger: "@logger" #Psr\Log\LoggerInterface
        httpClient: ... #Psr\Http\Client\ClientInterface
        asyncHttpClient: ... #Http\Client\HttpAsyncClient
        nodePool: ... #Elastic\Transport\NodePool\NodePoolInterface
        httpClientOptions: ... # podle http clienta
        api:
            apiKey: ""
            id: ""
        ssl:
            sslVerification: true/false
            sslCA: ""
            sslCert:
                cert: ""
                password: ""
            sslKey:
                key: ""
                password: ""

```

#### Registrace Playground

[](#registrace-playground)

```
when@dev:
    elasticsearch_profiler:
        resource: '@ElasticsearchBundle/Resources/config/routing.php'
```

#### Registrace Document Builder Factories

[](#registrace-document-builder-factories)

Pro registraci stačí dědit `DocumentBuilderFactoryInterface` a zaregistrovat jako service do kontejneru.

#### Key Resolver

[](#key-resolver)

ObjectType a NestedType disponuje možností resolvovat názvy fieldů. Pro Annotation driver je možné si nastavit globálně resolver přes keyResolver atribut (viz. yaml výše). Pokud z nějakého důvodu je potřeba u property vlastní resolver, tak je to možné udělat takto:

Vytvoříme si Custom resolver jako službu DI kontejneru a implementujeme rozhranní `KeyResolverInterface`.

a upravíme PHP atribut následovně:

```
#[NestedType(
   keyResolver: CustomKeyResolver::class,
   fieldsTemplate: new TextType(),
)]
protected array $sellingPrice = [];
```

#### Post Event callback

[](#post-event-callback)

Pokud potřebuji ještě nějaké dynamické prvky, pak si mohu u attributu index nastavit postEventClass a zaregistrovat service do kontejneru implementující rozhranní PostEventInterface. Například:

```
