gbprod/elasticsearch-extra-bundle

此包已弃用且不再维护。未建议替代包。

m6web/elasticsearch-bundle 的额外工具

v0.1.0 2016-03-25 21:02 UTC

This package is auto-updated.

Last update: 2020-06-07 07:56:57 UTC


README

stability-deprecated

我将不再维护此包,推荐使用 elastica-extra-bundle

Build Status Scrutinizer Code Quality Code Coverage

Latest Stable Version Total Downloads Latest Unstable Version License

管理索引和类型的额外工具。基于 m6web/elasticsearch-bundle 构建。

安装

使用 composer

composer require gbprod/elasticsearch-extra-bundle

更新你的 app/AppKernel.php 文件

public function registerBundles()
{
    $bundles = array(
        new M6Web\Bundle\ElasticsearchBundle\M6WebElasticsearchBundle(),
        new GBProd\ElasticsearchExtraBundle\ElasticsearchExtraBundle(),
    );
}

查看 M6WebElasticsearchBundle 配置客户端。

索引管理操作

配置

设置索引配置

elasticsearch_extra:
    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_index --client=my_client

删除索引

使用默认客户端

php app/console elasticsearch:index:delete my_index --force

或使用指定客户端

php app/console elasticsearch:index:delete my_index --force --client=my_client

设置索引设置

使用默认客户端

php app/console elasticsearch:index:put_settings my_index

或使用指定客户端

php app/console elasticsearch:index:put_settings my_index --client=my_client

设置索引映射

使用默认客户端

php app/console elasticsearch:index:put_mappings my_index my_type

或使用指定客户端

php app/console elasticsearch:index:put_mappings my_index my_type --client=my_client