Giter VIP home page Giter VIP logo

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.