ElasticSearch 协程客户端 - 分析文档

分析

field 分析用法

  1. <?php
  2. $config = new \EasySwoole\ElasticSearch\Config([
  3. 'host' => '127.0.0.1',
  4. 'port' => 9200
  5. ]);
  6. $elasticsearch = new \EasySwoole\ElasticSearch\ElasticSearch($config);
  7. go(function () use ($elasticsearch) {
  8. $bean = new \EasySwoole\ElasticSearch\RequestBean\FieldCaps();
  9. $bean->setIndex('my-index');
  10. $bean->setFields('test-field');
  11. $response = $elasticsearch->client()->fieldCaps($bean)->getBody();
  12. $response = json_decode($response, true);
  13. var_dump($response);
  14. });

query 分析用法

  1. <?php
  2. $config = new \EasySwoole\ElasticSearch\Config([
  3. 'host' => '127.0.0.1',
  4. 'port' => 9200
  5. ]);
  6. $elasticsearch = new \EasySwoole\ElasticSearch\ElasticSearch($config);
  7. go(function () use ($elasticsearch) {
  8. $bean = new \EasySwoole\ElasticSearch\RequestBean\Explain();
  9. $bean->setIndex('my-index');
  10. $bean->setId('my-id');
  11. $bean->setBody([
  12. 'query' => [
  13. 'bool' => [
  14. 'must' => [
  15. ['match' =>
  16. [
  17. 'test-field' => 'abd'
  18. ]
  19. ]
  20. ]
  21. ]
  22. ]
  23. ]);
  24. $response = $elasticsearch->client()->explain($bean)->getBody();
  25. $response = json_decode($response, true);
  26. var_dump($response);
  27. });