日韩在线观看-日韩在线成人-日韩在线不卡视频-日韩在线不卡视频-国产精品99-国产精品99

ElasticSearch 協程客戶端 - 查詢文檔

查詢

根據 文檔ID 查詢 document 用法

<?php
$config = new \EasySwoole\ElasticSearch\Config([
    'host' => '127.0.0.1',
    'port' => 9200
]);

$elasticsearch = new \EasySwoole\ElasticSearch\ElasticSearch($config);

go(function () use ($elasticsearch) {
    $bean = new \EasySwoole\ElasticSearch\RequestBean\Get();
    $bean->setIndex('my-index');
    $bean->setType('my-type');
    $bean->setId('my-id');
    $response = $elasticsearch->client()->get($bean)->getBody();
    var_dump(json_decode($response, true));
});

根據 文檔ID 批量查詢 document 用法

<?php
$config = new \EasySwoole\ElasticSearch\Config([
    'host' => '127.0.0.1',
    'port' => 9200
]);

$elasticsearch = new \EasySwoole\ElasticSearch\ElasticSearch($config);

go(function () use ($elasticsearch) {
    $bean = new \EasySwoole\ElasticSearch\RequestBean\Mget();
    $bean->setIndex('my-index');
    $bean->setType('my-type');
    $bean->setBody(['ids' => ['my-id', '1']]);
    $response = $elasticsearch->client()->mget($bean)->getBody();
    var_dump(json_decode($response, true));
});

根據 文檔ID 查詢 source 用法

<?php
$config = new \EasySwoole\ElasticSearch\Config([
    'host' => '127.0.0.1',
    'port' => 9200
]);

$elasticsearch = new \EasySwoole\ElasticSearch\ElasticSearch($config);

go(function () use ($elasticsearch) {
    $bean = new \EasySwoole\ElasticSearch\RequestBean\Get();
    $bean->setIndex('my-index');
    $bean->setType('my-type');
    $bean->setId('my-id');
    $response = $response = $elasticsearch->client()->getSource($bean)->getBody();
    var_dump(json_decode($response, true));
});

query 查詢用法

<?php
$config = new \EasySwoole\ElasticSearch\Config([
    'host' => '127.0.0.1',
    'port' => 9200
]);

$elasticsearch = new \EasySwoole\ElasticSearch\ElasticSearch($config);

go(function () use ($elasticsearch) {
    $bean = new \EasySwoole\ElasticSearch\RequestBean\Search();
    $bean->setIndex('my-index');
    $bean->setType('my-type');
    $bean->setBody(['query' => ['match' => ['test-field' => 'ab']]]);
    $response = $elasticsearch->client()->search($bean)->getBody();
    var_dump(json_decode($response, true));
});

查詢總數用法

<?php
$config = new \EasySwoole\ElasticSearch\Config([
    'host' => '127.0.0.1',
    'port' => 9200
]);

$elasticsearch = new \EasySwoole\ElasticSearch\ElasticSearch($config);

go(function () use ($elasticsearch) {
    $bean = new \EasySwoole\ElasticSearch\RequestBean\Count();
    $response = $elasticsearch->client()->count($bean)->getBody();
    $response = json_decode($response, true);
    var_dump($response['count']);
});

scroll 分頁查詢用法

<?php
$config = new \EasySwoole\ElasticSearch\Config([
    'host' => '127.0.0.1',
    'port' => 9200
]);

$elasticsearch = new \EasySwoole\ElasticSearch\ElasticSearch($config);

go(function () use ($elasticsearch) {
    $sBean = new \EasySwoole\ElasticSearch\RequestBean\Search();
    $sBean->setIndex('my-index');
    $sBean->setScroll('1m');
    $sBean->setBody([
        'query' => [
            'match' => [
                'test-field' => 'abd'
            ]
        ],
        'sort' => ['_doc'],
        'size' => 1
    ]);
    $sResponse = $elasticsearch->client()->search($sBean)->getBody();
    $sResponse = json_decode($sResponse, true);

    $bean = new \EasySwoole\ElasticSearch\RequestBean\Scroll();
    $bean->setScrollId($sResponse['_scroll_id']);
    $bean->setScroll('1m');
    $response = $elasticsearch->client()->scroll($bean)->getBody();
    var_dump(json_decode($response, true));
});

template 查詢用法

<?php
$config = new \EasySwoole\ElasticSearch\Config([
    'host' => '127.0.0.1',
    'port' => 9200
]);

$elasticsearch = new \EasySwoole\ElasticSearch\ElasticSearch($config);

go(function () use ($elasticsearch) {
    $bean = new \EasySwoole\ElasticSearch\RequestBean\SearchTemplate();
    $bean->setIndex('my-index');
    $bean->setType('my-type');
    $bean->setBody([
        'inline' =>
            [
                'query' =>
                    [
                        'match' => ["{{field}}" => "{{value}}"]
                    ]
            ],
        'params' =>
            [
                'field' => 'test-field',
                'value' => '博客'
            ]
    ]);
    $response = $elasticsearch->client()->searchTemplate($bean)->getBody();
    var_dump(json_decode($response, true));
});

termVectors 用法

<?php
$config = new \EasySwoole\ElasticSearch\Config([
    'host' => '127.0.0.1',
    'port' => 9200
]);

$elasticsearch = new \EasySwoole\ElasticSearch\ElasticSearch($config);

go(function () use ($elasticsearch) {
    $bean = new \EasySwoole\ElasticSearch\RequestBean\TermVectors();
    $bean->setIndex('my-index');
    $bean->setType('my-type');
    $bean->setId('my-id');
    $bean->setPretty(true);
    $bean->setBody([
        'fields' => ['test-field'],
        'offsets' => true,
        'payloads' => true,
        'positions' => true,
        "term_statistics" => true,
        "field_statistics" => true
    ]);
    $response = $elasticsearch->client()->termvectors($bean)->getBody();
    var_dump(json_decode($response, true));
});

分片信息查詢用法

<?php
$config = new \EasySwoole\ElasticSearch\Config([
    'host' => '127.0.0.1',
    'port' => 9200
]);

$elasticsearch = new \EasySwoole\ElasticSearch\ElasticSearch($config);

go(function () use ($elasticsearch) {
    $bean = new \EasySwoole\ElasticSearch\RequestBean\SearchShards();
    $bean->setIndex('my-index');
    $response = $elasticsearch->client()->searchShards($bean)->getBody();
    $response = json_decode($response, true);
    var_dump($response);
});

節點狀態獲取用法

<?php
$config = new \EasySwoole\ElasticSearch\Config([
    'host' => '127.0.0.1',
    'port' => 9200
]);

$elasticsearch = new \EasySwoole\ElasticSearch\ElasticSearch($config);

go(function () use ($elasticsearch) {
    $bean = new \EasySwoole\ElasticSearch\RequestBean\Info();
    $response = $elasticsearch->client()->info($bean)->getBody();
    $response = json_decode($response, true);
    var_dump($response);
});
主站蜘蛛池模板: 清纯女被强行开了处视频| 成人免费视频在线播放| 刑三狗| 俺去也电影网| psv游戏| 日本电影芋虫| 男人不可以穷演员表| 赵大勇| 崔维斯·费米尔| 程小西| 2013年9月份日历表| 调教vk| 音乐僵尸| 天道全集| 瑞斯·伊凡斯| 歌曲串烧串词| www.56.com| 名星| 浙江卫视台节目表| 小淘气尼古拉| 零下的风 完整版| 刘德华的歌曲经典| 极寒复出| 各各他的路赞美诗歌| 广西都市频道节目表| 同志父子第二部叫什么| 永恒万花筒佐助壁纸| 叶玲| 大海啊故乡钢琴谱| 禁忌的游戏| 林莉娴| 1024电影| 加濑亮| 欧美大片在线视频| 新爱情乐园| 生活秀| 威虎山黑话大全口令| 黄金太阳2| 狗年龄| 年轻的丈夫| 大胆艺术|