elasticsearch.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. return [
  3. /**
  4. * Here you can specify the connection to use when building a client.
  5. */
  6. 'connection' => 'default',
  7. /**
  8. * These are the available connections parameters that you can use to connect
  9. */
  10. 'connections' => [
  11. 'default' => [
  12. 'hosts' => [
  13. env('ELASTICSEARCH_HOST', 'http://localhost:9200'),
  14. ],
  15. 'user' => env('ELASTICSEARCH_USER', null),
  16. 'pass' => env('ELASTICSEARCH_PASS', null),
  17. ],
  18. /**
  19. * You can connect with API key authentication by setting the `api` key
  20. * instead of the `user` and `pass` keys.
  21. */
  22. 'api' => [
  23. 'hosts' => [
  24. env('ELASTICSEARCH_HOST', null),
  25. ],
  26. 'key' => env('ELASTICSEARCH_API_KEY', null),
  27. ],
  28. /**
  29. * You can connect to Elastic Cloud with the Cloud ID using the `cloud` key.
  30. */
  31. 'cloud' => [
  32. 'id' => env('ELASTICSEARCH_CLOUD_ID', null),
  33. /**
  34. * If you are authenticating with API KEY then set user and pass as null
  35. */
  36. 'api_key' => env('ELASTICSEARCH_API_KEY', null),
  37. /**
  38. * If you are authenticating with username and password then set api_key as null
  39. */
  40. 'user' => env('ELASTICSEARCH_USER', null),
  41. 'pass' => env('ELASTICSEARCH_PASS', null),
  42. ],
  43. ],
  44. /**
  45. * CA Bundle
  46. *
  47. * OrbStack (*.orb.local) uses its own root CA; direct ES uses http_ca.crt.
  48. * Override with ELASTICSEARCH_CA_BUNDLE in .env when needed.
  49. *
  50. * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/connecting.html#auth-http
  51. */
  52. 'caBundle' => (function () {
  53. $bundle = env('ELASTICSEARCH_CA_BUNDLE');
  54. if ($bundle && ! str_starts_with($bundle, '/')) {
  55. $bundle = base_path($bundle);
  56. }
  57. if ($bundle && is_readable($bundle)) {
  58. return $bundle;
  59. }
  60. foreach ([public_path('orbstack_ca.crt'), public_path('elastic_ca.crt')] as $candidate) {
  61. if (is_readable($candidate)) {
  62. return $candidate;
  63. }
  64. }
  65. return null;
  66. })(),
  67. /**
  68. * Retries
  69. *
  70. * By default, the client will retry n times, where n = number of nodes in
  71. * your cluster. If you would like to disable retries, or change the number,
  72. * you can do so here.
  73. *
  74. * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/set-retries.html
  75. */
  76. 'retries' => null,
  77. ];