<?php
use Elasticsearch\ClientBuilder;
$client = ClientBuilder::create()->setHosts(['kubernetes.docker.internal:9200'])->build();
$client->indices()->create([
// 索引名
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
// 字段名
'testField' => [
'type' => 'keyword',
]
],
]
]
]);
[Elasticsearch]ElasticSearch7.11通过PHP创建无分析器索引
于 2022-02-22 15:08:01 首次发布
这段代码展示了如何使用Elasticsearch的ClientBuilder创建一个名为'my_index'的索引,并定义一个名为'testField'的keyword类型字段。这个过程对于设置搜索引擎或者数据分析的底层结构至关重要。


3633

被折叠的 条评论
为什么被折叠?



