Giter VIP home page Giter VIP logo

elasticsearch's Introduction

elasticsearch

Elasticsearch client,对官方客户端的协程化移植

单元测试

php vendor/bin/co-phpunit tests

单元测试前请修改项目根目录下phpunit.php内的配置项

官方Docker

docker pull elasticsearch:7.10.1
docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.10.1

参考文献

https://github.com/elastic/elasticsearch-php/blob/master/src/Elasticsearch/Client.php

https://github.com/elastic/elasticsearch-php/blob/master/src/Elasticsearch/ClientBuilder.php

elasticsearch's People

Contributors

kiss291323003 avatar player626 avatar xiaocaigua avatar hlhill avatar

Stargazers

Cloudflying avatar Yushan Lin avatar  avatar 佟梁 avatar  avatar giantwu avatar  avatar kongkongyzt avatar luckyforme233 avatar mkerp avatar TiX avatar herder wu avatar 北溟有鱼QAQ avatar  avatar

Watchers

James Cloos avatar

elasticsearch's Issues

创建文档时候抛出错误

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";
}

关于elasticsearch建立索引,返回值为空

代码如下:
$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));

结果如下:
图片

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.