elasticsearch php权重,Elasticsearch-PHP索引管理操作

创建索引$params = ['index' => 'test'];

$client->indices()->create($params);

这里index是必填参数,除此之外,还有两个可选参数:timeout、body。timeout是设置超时时间,body是一个数组,可以接收mappings,settings等。删除索引$client->indices()->delete(['index' => 'test']);设置索引

前面创建索引说到可以将settings等通过body传入,也可以单独调用接口设置:$params = [

'index' => 'my_index',

'body' => [

'settings' => [

'number_of_replicas' => 0,

'refresh_interval' => -1

]

]

];

$response = $client->indices()->putSettings($params);获取索引设置// 单个获取

$params = ['index' => 'my_index'];

$response = $client->indices()->getSettings($params);

// 同时获取多个

$params = [

'index' => [ 'my_index', 'my_index2' ]

];

$response = $client->indices()->getSettings($params);设置mappings

settings可以单独设置,mappings也一样可以单独设置。// Set the index and type

$params = [

'index' => 'my_index',

'body' => [

'_source' => [

'enabled' => true

],

'properties' => [

'first_name' => [

'type' => 'text',

'analyzer' => 'standard'

],

'age' => [

'type' => 'integer'

]

]

]

];

// Update the index mapping

$client->indices()->putMapping($params);获取mappings// Get mappings for all indexes

$response = $client->indices()->getMapping();

// Get mappings in 'my_index'

$params = ['index' => 'my_index'];

$response = $client->indices()->getMapping($params);

// Get mappings for two indexes

$params = [

'index' => [ 'my_index', 'my_index2' ]

];

$response = $client->indices()->getMapping($params);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值