BxElsModule.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup ElasticSearch ElasticSearch
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxElsModule extends BxBaseModGeneralModule
  12. {
  13. function __construct(&$aModule)
  14. {
  15. parent::__construct($aModule);
  16. }
  17. public function actionDebug()
  18. {
  19. bx_import('Api', $this->_aModule);
  20. $o = new BxElsApi();
  21. // search all
  22. // $mixed = $o->api('/testdata/_search?q=*');
  23. // $mixed = $o->api('/testdata/_search', ['query' => ['match_all' => (object)[]]]);
  24. // search for the term
  25. // $mixed = $o->api('/testdata/_search', ['query' => ['simple_query_string' => ['query' => 'palm']]]);
  26. // $mixed = $o->api('/testdata/_search?q=palm');
  27. // search in a field
  28. // $mixed = $o->api('/testdata/_search', ['query' => ['simple_query_string' => ['query' => 'palm', 'fields' => ['name']]]]);
  29. // delete indexed doc
  30. // $mixed = $o->api('/testdata/trees/23', [], 'delete');
  31. // get indexed doc
  32. // $mixed = $o->api('/testdata/trees/23');
  33. // index a doc
  34. // $mixed = $o->indexData('testdata', 'trees', 23, ['name' => 'apple tree', 'fruits' => 'apples']);
  35. // $mixed = $o->indexData('testdata', 'trees', 24, ['name' => 'palm', 'fruits' => 'coconuts']);
  36. // get indexes
  37. // $mixed = $o->api('/_cat/indices');
  38. // add index
  39. // $mixed = $o->api('/testdata', [], 'PUT');
  40. // test
  41. $mixed = $o->api('/_cat/health');
  42. echo '<pre>';
  43. if (null === $mixed)
  44. echo $o->getErrorMsg();
  45. else
  46. var_dump($mixed);
  47. echo '</pre>';
  48. }
  49. public function serviceAdd($sString, $iLanguageId = 0, $iOrig = 1)
  50. {
  51. }
  52. public function serviceEdit($iKeyId, $sString, $iLanguageId = 0, $bMarkAsOrig = false, $bRemoveOther = false)
  53. {
  54. }
  55. public function serviceDelete($iKeyId)
  56. {
  57. }
  58. }
  59. /** @} */