gbprod / elastica-extra-bundle
该软件包已被废弃,不再维护。未建议替代软件包。
提供额外 elastica 工具的索引和类型设置的软件包
v1.1.0
2018-01-23 11:05 UTC
Requires
- php: >=5.6
- ruflin/elastica: ^3.1|^5.0|^6.0
- symfony/console: ^2.7|^3.0|^4.0
- symfony/framework-bundle: ^2.7|^3.0|^4.0
- symfony/yaml: ^2.7|^3.0|^4.0
Requires (Dev)
- phpunit/phpunit: ^5.7|^6.0
This package is auto-updated.
Last update: 2021-08-07 10:20:23 UTC
README
提供额外 elastica 工具的索引和类型设置的软件包。
使用此软件包,您可以
- 使用 yaml 管理索引设置和映射
- 创建和删除索引
- 管理索引的别名
- 重新索引
安装
使用 composer
composer require gbprod/elastica-extra-bundle
更新您的 app/AppKernel.php
文件
public function registerBundles() { $bundles = array( new GBProd\ElasticaExtraBundle\ElasticaExtraBundle(), ); }
配置 Elastica 客户端
gbprod_elastica_extra: default_client: 'elastica.default_client' # Elastica client service's name
您可以使用类似以下软件包创建 Elastica 客户端:
- FOSElasticaBundle 服务名称将类似于
fos_elastica.client.my_client
- 我的轻量级软件包 ElasticaBundle 服务名称将类似于
elastica.default_client
- DIY
索引管理操作
配置
设置索引配置
elastica_extra: default_client: 'elastica.default_client' indices: my_index: settings: number_of_shards: 3 number_of_replicas: 2 mappings: my_type: _source: enabled: true properties: first_name: type: string analyzer: standard age: type: integer my_index_2: ~
创建索引
将使用其配置创建索引。
php app/console elasticsearch:index:create my_index
将使用另一个索引配置创建索引(在使用别名时很有用)。
php app/console elasticsearch:index:create my_versionned_index --alias=my_index
删除索引
php app/console elasticsearch:index:delete my_index --force
设置索引设置
php app/console elasticsearch:index:put_settings my_index
将使用另一个索引配置设置索引设置(在使用别名时很有用)。
php app/console elasticsearch:index:put_settings my_versionned_index --alias=my_index
设置索引映射
php app/console elasticsearch:index:put_mappings my_index my_type
将使用另一个索引配置设置索引映射(在使用别名时很有用)。
php app/console elasticsearch:index:put_mappings my_versionned_index my_type --alias=my_index
别名管理操作
列出索引的别名
php app/console elasticsearch:alias:list my_index
为索引添加别名
php app/console elasticsearch:alias:add my_index my_alias
如果设置了 --replace
选项,现有别名将被替换。
php app/console elasticsearch:alias:add my_index my_alias --replace
为索引删除别名
php app/console elasticsearch:alias:remove my_index my_alias
列出索引
此命令列出索引。
php app/console elasticsearch:index:list
您还可以使用正则表达式过滤显示的索引。
php app/console elasticsearch:index:list --pattern="user*"
重新索引
此命令使用 reindex API 进行重新索引。
php app/console elasticsearch:reindex [old-index] [new-index]
使用不同的客户端
对于所有命令,您都可以使用 --client
选项指定不同的客户端。
例如
php app/console elasticsearch:index:create my_index --client=my_client_service