Elasticsearch创建索引
2016-09-04 23:13
288 查看
<?php namespace CronBundle\Command\Elasticsearch; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Elasticsearch\ClientBuilder; /** * command name : app/console elasticsearch:create:index */ class CreateIndexCommand extends Command { public function __construct() { parent::__construct(); } protected function configure() { $this ->setName('elasticsearch:create:index') ->setDescription('') ->addOption( 'yell', null, InputOption::VALUE_NONE, 'If set, the task will yell in uppercase letters' ) ; } protected function execute(InputInterface $input, OutputInterface $output) { $client = ClientBuilder::create()->build(); $params = [ 'index' => 'caishen_index', 'body' => [ 'settings' => [ 'number_of_replicas' => 0, ], 'mappings' => [ 'default_type' => [ 'properties' => [ 'name' => [ 'type' => 'string', 'analyzer' => 'ik' ], 'name_pinyin' => [ 'type' => 'string', 'analyzer' => 'pinyin_ngram_analyzer' ], 'keywords' => [ 'type' => 'string' ] ], ], ], ], ]; $client->indices()->create($params); $output->writeln('create user account successfully'); } }
相关文章推荐
- Elasticsearch5.3 用JAVA创建索引
- ElasticSearch初步学习,创建索引(入门一)
- Elasticsearch通过JAVA创建索引、Mapping以及数据的增删该查操作
- Elasticsearch 学习笔记 索引创建、插入、查询、修改、删除
- ElasticSearch49:索引管理_快速上机动手实战创建、修改以及删除索引
- Elasticsearch之创建索引、删除索引、索引设置、配置分析器、自定义分析器。
- Elasticsearch创建索引和映射结构详解
- elasticsearch创建索引报错
- ElasticSearch源码解析(三):索引创建
- Elasticsearch创建索引和映射结构详解
- elasticsearch-jdbc 使用数据库数据创建索引
- Elasticsearch之curl创建索引
- elasticsearch核心知识--47.创建更新删除索引以及自定义分词器。
- elasticsearch 字段别名(创建索引并指定索引类型的mapping)
- Elasticsearch创建索引
- Elasticsearch索引创建快照
- perl put 请求创建elasticsearch 索引
- Java操作ElasticSearch之创建索引
- Elasticsearch生成json,创建索引(把数据写入索引中)
- ElasticSearch创建索引(index)和添加映射(mapping)