easy-swoole / elasticsearch Goto Github PK
View Code? Open in Web Editor NEWElasticsearch client
License: Apache License 2.0
Elasticsearch client
License: Apache License 2.0
vendor\easyswoole\elasticsearch\src\Endpoints\Create.php
代码段
public function getURI(): string
{
if (isset($this->id) !== true) {
throw new RuntimeException(
'id is required for create'
);
}
$id = $this->id;
if (isset($this->index) !== true) {
throw new RuntimeException(
'index is required for create'
);
}
$index = $this->index;
var_dump($this->type);
$type = $this->type ?? null;
if (isset($type)) { //这里的判断是不是有问题?不建议url传送类型,那么这个扩展包还有其他的方法吗?
@trigger_error('Specifying types in urls has been deprecated', E_USER_DEPRECATED);
}
if (isset($type)) {
return "/$index/$type/$id/_create";
}
return "/$index/_create/$id";
}
代码如下:
$config = new \EasySwoole\ElasticSearch\Config([
'host' => 'es01',
'port' => 9200,
'username' => 'elastic',
'password' => 'xxxxxxxxx',
'scheme' => 'https'
]);
$elasticsearch = new \EasySwoole\ElasticSearch\ElasticSearch($config);
go(function () use ($elasticsearch) {
$bean = new \EasySwoole\ElasticSearch\RequestBean\Bulk();
$bean->setIndex('log_web');
//$bean->setType('log');
$body = [];
for ($i = 1; $i <= 5; $i++) {
$body[] = [
'create' => [
'_index' => 'my-index',
'_type' => 'my-type',
'_id' => $i * 1000
]
];
$body[] = [
'test-field' => 'test-data',
];
}
$bean->setBody($body);
$response = $elasticsearch->client()->bulk($bean)->getBody();
var_dump(json_decode($response, true));
es协程客户端没有支持mappings的设置吗
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.