composer require aternovtsii/search-bundle
<?php
return [
// ...
ATSearchBundle\ATSearchBundle::class => ['all' => true],
];
doctrine:
orm:
dql:
numeric_functions:
IFNULL: ATSearchBundle\Doctrine\Extensions\Query\IfNull
JSON_CONTAINS: ATSearchBundle\Doctrine\Extensions\Query\JsonContains
RAND: ATSearchBundle\Doctrine\Extensions\Query\Rand
at_search:
search:
enabled: true
client: OpenSearch\Client # OpenSearch\Client or Elasticsearch\Client
mappings:
App:
namespace: App\Entity
dir: '%kernel.project_dir%/src/Entity'
OpenSearch\Client:
factory: ['OpenSearch\ClientBuilder', 'fromConfig']
arguments:
$config:
hosts: ['%env(OPENSEARCH_URL)%']
Elasticsearch\Client:
factory: ['Elasticsearch\ClientBuilder', 'fromConfig']
arguments:
$config:
hosts: ['%env(ELASTICSEARCH_URL)%']
<?php
namespace App\Entity;
use ATSearchBundle\Annotation as ATSearch;
use Doctrine\ORM\Mapping as ORM;
#[ATSearch\Index]
#[ORM\Entity]
class User
{
#[ATSearch\FieldId]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
public ?int $id = null;
#[ATSearch\FieldString]
#[ORM\Column(length: 128)]
public ?string $firstName = null;
#[ATSearch\FieldMultiString(subFields: 'email')]
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Email::class)]
public Collection $emails;
To enable default reindex based on Doctrine events add the following to your config/packages/at_search.yaml file
at_search:
search:
enable_update_events: true # default false