Skip to content

v3.8.2

Compare
Choose a tag to compare
@pdphilip pdphilip released this 06 Jun 13:09
· 410 commits to main since this release

New Features

New numeric type mappings for IndexBlueprint

  • double($field) - A double-precision 64-bit IEEE 754 floating point number, restricted to finite values.
  • byte($field) - A signed 8-bit integer with a minimum value of -128 and a maximum value of 127.
  • halfFloat($field) - A half-precision 16-bit IEEE 754 floating point number, restricted to finite values.
  • scaledFloat($field, $scalingFactor = 100) - A floating point number that is backed by a long, scaled by a fixed double scaling factor.
  • unsignedLong($field) - An unsigned 64-bit integer with a minimum value of 0 and a maximum value of 264-1.

Example:

  Schema::create('my_index', function (IndexBlueprint $index) {
      $index->double('some_field_a');
      $index->byte('some_field_b');
      $index->halfFloat('some_field_c');
      $index->scaledFloat('some_field_d', 100);
      $index->unsignedLong('some_field_e');
  });

Upgrades

  • Upgraded Connection class to parse the config's connection name. This allows for multiple connections or if you define your connection in the database file something other than elasticsearch

Example with multiple connections (database.php):

 'elasticsearch'       => [
    'driver'       => 'elasticsearch',
    'auth_type'    => env('ES_AUTH_TYPE', 'http'), //http, cloud or api
    'hosts'        => explode(',', env('ES_HOSTS', 'http://localhost:9200')),
    'username'     => env('ES_USERNAME', ''),
    'password'     => env('ES_PASSWORD', ''),
    'cloud_id'     => env('ES_CLOUD_ID', ''),
    'api_id'       => env('ES_API_ID', ''),
    'api_key'      => env('ES_API_KEY', ''),
    'ssl_cert'     => env('ES_SSL_CA', ''),
    'ssl'          => [
        'cert'          => env('ES_SSL_CERT', ''),
        'cert_password' => env('ES_SSL_CERT_PASSWORD', ''),
        'key'           => env('ES_SSL_KEY', ''),
        'key_password'  => env('ES_SSL_KEY_PASSWORD', ''),
    ],
    'index_prefix' => env('ES_INDEX_PREFIX', false),
    'options'      => [
        'allow_id_sort'    => env('ES_OPT_ID_SORTABLE', false),
        'ssl_verification' => env('ES_OPT_VERIFY_SSL', true),
        'retires'          => env('ES_OPT_RETRIES', null),
        'meta_header'      => env('ES_OPT_META_HEADERS', true),
    ],
    'query_log'    => [
        'index'      => false,
        'error_only' => true,
    ],
],
'elasticsearch-cloud' => [
    'driver'       => 'elasticsearch',
    'auth_type'    => env('ES_CLOUD_AUTH_TYPE', 'http'), //http or cloud
    'hosts'        => explode(',', env('ES_CLOUD_HOSTS', 'http://localhost:9200')),
    'username'     => env('ES_CLOUD_USERNAME', ''),
    'password'     => env('ES_CLOUD_PASSWORD', ''),
    'cloud_id'     => env('ES_CLOUD_CLOUD_ID', ''),
    'api_id'       => env('ES_CLOUD_API_ID', ''),
    'api_key'      => env('ES_CLOUD_API_KEY', ''),
    'ssl_cert'     => env('ES_CLOUD_SSL_CA', ''),
    'ssl'          => [
        'cert'          => env('ES_CLOUD_SSL_CERT', ''),
        'cert_password' => env('ES_CLOUD_SSL_CERT_PASSWORD', ''),
        'key'           => env('ES_CLOUD_SSL_KEY', ''),
        'key_password'  => env('ES_CLOUD_SSL_KEY_PASSWORD', ''),
    ],
    'index_prefix' => env('ES_CLOUD_INDEX_PREFIX', false),
    'options'      => [
        'allow_id_sort'    => env('ES_CLOUD_OPT_ID_SORTABLE', false),
        'ssl_verification' => env('ES_CLOUD_OPT_VERIFY_SSL', true),
        'retires'          => env('ES_CLOUD_OPT_RETRIES', null),
        'meta_header'      => env('ES_CLOUD_OPT_META_HEADERS', true),
    ],
    'query_log'    => [
        'index'      => false,
        'error_only' => true,
    ],
],

Examples of selecting connection:

Schema::on('elasticsearch-cloud')->create('my_index', ...... );
Product::on('elasticsearch-cloud')->get() //If $connection in Product model is not 'elasticsearch-cloud';