aternovtsii/search-bundle
最新稳定版本:v1.2.2
Composer 安装命令:
composer require aternovtsii/search-bundle
包简介
Symfony bundle for easy integration with elastic/opensearch search engine and doctrine
README 文档
README
composer require aternovtsii/search-bundle
To enable bundle add the following to your config/bundles.php file
<?php return [ // ... ATSearchBundle\ATSearchBundle::class => ['all' => true], ];
To enable additional doctrine filters add the following to your config/doctrine.yaml file
doctrine: orm: dql: numeric_functions: IFNULL: ATSearchBundle\Doctrine\Extensions\Query\IfNull JSON_CONTAINS: ATSearchBundle\Doctrine\Extensions\Query\JsonContains RAND: ATSearchBundle\Doctrine\Extensions\Query\Rand
Configure bundle in your config/packages/at_search.yaml file
at_search: search: enabled: true client: OpenSearch\Client # OpenSearch\Client or Elasticsearch\Client mappings: App: namespace: App\Entity dir: '%kernel.project_dir%/src/Entity'
To create OpenSearch Client add the following to your config/services.yaml file
OpenSearch\Client: factory: ['OpenSearch\ClientBuilder', 'fromConfig'] arguments: $config: hosts: ['%env(OPENSEARCH_URL)%']
To create ElasticSearch Client add the following to your config/services.yaml file
Elasticsearch\Client: factory: ['Elasticsearch\ClientBuilder', 'fromConfig'] arguments: $config: hosts: ['%env(ELASTICSEARCH_URL)%']
Usage example
<?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
统计信息
- 总下载量: 278
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-18