Skip to content

Releases: pdphilip/laravel-opensearch

v3.0.1

04 Jun 12:06
Compare
Choose a tag to compare

This release is compatible with Laravel 10, 11 & 12

What's Changed
Bug fix: Chunking $count value fixed for setting query limit correctly, via pdphilip/laravel-elasticsearch#68

Full Changelog: v3.0.0...v3.0.1

v3.0.0

13 Apr 00:00
Compare
Choose a tag to compare

We’re excited to announce v3 of the laravel-opensearch package - compatible with Laravel 10, 11, and 12.

Intro

V3 is a near-complete rewrite of the package; packed with powerful new features, deep integration with OpensSearch's full capabilities, and a much tighter alignment with Laravel’s Eloquent. It lays a solid, future-proof foundation for everything that comes next.

Upgrading

"pdphilip/opensearch": "^3",

Breaking Changes

1. Connection

  • Index Prefix Handling
    The OS_INDEX_PREFIX no longer auto-appends an underscore (_).
    Old behavior: OS_INDEX_PREFIX=my_prefixmy_prefix_
    New: set explicitly if needed → OS_INDEX_PREFIX=my_prefix_

2. Models

  • Model ID Field
    $model->_id is deprecated. Use $model->id instead.
    If your model had a separate id field, you must rename it.

  • Default Limit Constant
    MAX_SIZE constant is removed. Use $defaultLimit property:

    use PDPhilip\OpensSearch\Eloquent\Model;
    
    class Product extends Model
    {
        protected $defaultLimit = 10000;
        protected $connection = 'opensearch';
    }

3. Queries

  • where() Behavior Changed

    Now uses term query instead of match.

    // Old:
    Product::where('name', 'John')->get(); // match query
    // New:
    Product::whereMatch('name', 'John')->get(); // match query
    Product::where('name', 'John')->get();      // term query
  • orderByRandom() Removed

    Replace with functionScore() Docs

  • Full-text Search Options Updated
    Methods like asFuzzy(), setMinShouldMatch(), setBoost() removed.
    Use callback-based SearchOptions instead:

    Product::searchTerm('espresso time', function (SearchOptions $options) {
        $options->searchFuzzy();
        $options->boost(2);
        $options->minimumShouldMatch(2);
    })->get();
  • Legacy Search Methods Removed
    All {xx}->search() methods been removed. Use {multi_match}->get() instead.

4. Distinct & GroupBy

  • distinct() and groupBy() behavior updated. Docs

    Review queries using them and refactor accordingly.

5. Schema

  • IndexBlueprint and AnalyzerBlueprint has been removed and replaced with a single Blueprint class

    -   use PDPhilip\OpensSearch\Schema\IndexBlueprint;
    -   use PDPhilip\OpensSearch\Schema\AnalyzerBlueprint;
    use PDPhilip\OpensSearch\Schema\Blueprint;
  • Schema::hasIndex has been removed. Use Schema::hasTable or Schema::indexExists instead.

  • geo($field) field property has been replaced with geoPoint($field)

  • {field}->index($bool) field property has been replaced with {field}->indexField($bool);

  • alias() field type has been removed. Use aliasField() instead.

  • settings() method has been replaced with withSetting()

  • map() method has been replaced with withMapping()

  • analyzer() method has been replaced with addAnalyzer()

  • tokenizer() method has been replaced with addTokenizer()

  • charFilter() method has been replaced with addCharFilter()

  • filter() method has been replaced with addFilter()

6. Dynamic Indices

  • Dynamic indices are now managed by the DynamicIndex trait. upgrade guide

New features

1. Laravel-Generated IDs

  • You can now generate OpensSearch ids in Laravel Docs

2. Fluent query options as a callback

  • All clauses in the query builder now accept an optional callback of OpensSearch options to be applied to the clause. Docs

3. Belongs to Many Relationships

  • Belongs to many relationships are now supported. Docs

4. New queries

5. New aggregations

  • Stats Aggregations Docs
  • Extended Stats Aggregations - Docs
  • Cardinality Aggregations - Docs
  • Median Absolute Deviation Aggregations - Docs
  • Percentiles Aggregations - Docs

6. Migrations: Add Normalizer

  • Normalizers can now be defined in migrations. Docs

7. Direct Access to OpensSearch PHP client

Connection::on('opensearch')-> openClient()->{clientMethod}();

Full Changelog: v2.0.6...v3.0.0

v2.0.6

12 Apr 19:48
Compare
Choose a tag to compare

What's Changed

Full Changelog: v2.0.5...v2.0.6

v2.0.5

25 Mar 14:48
32dbefe
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v2.0.4...v2.0.5

v2.0.4

05 Nov 09:38
b5e3070
Compare
Choose a tag to compare

What's Changed

  • query operator as lowercase to escape case-sensitive troubles. by @sergoslav in #9

New Contributors

Full Changelog: v2.0.3...v2.0.4

v2.0.3

17 Aug 21:59
Compare
Choose a tag to compare

This unified release includes updates for multiple Laravel versions:


Upgrades

  • sum(), avg(), min() and max() can now process multiple fields in one call
Product::where('color','blue')->avg(['orders', 'price']);
//Previously required two separate calls:
Product::where('color','blue')->avg('orders');
Product::where('color','blue')->avg('price');
  • rawSearch(array $bodyParams, bool $returnRaw = false)
  • a second bool parameter will return data as is (unsanitized) if set to true
Product::rawSearch($body, true);

Bug fixes

  • rawAggregation with multiple aggregations now returns all aggs
  • Fixed issue when saving fields where the data didn't change threw an error

Full Changelog: v2.0.2...v2.0.3

v2.0.2 - (Unified with v1.0.2)

02 Aug 11:45
Compare
Choose a tag to compare

This unified release includes updates for multiple Laravel versions:

New Features

wherePhrasePrefix($field, $phraseWithPrefix)

Method for looking up a specific sequence of words where the last word starts with a particular prefix

Person::wherePhrasePrefix('description', 'loves es')->get();
// returns: loves espresso, loves essays, loves eskimos, etc

Docs: https://opensearch.pdphilip.com/os-specific#where-phrase-prefix

phrase($field)

Method for searching across multiple fields for a specific phrase (sequence of words in order)

Book::phrase('United States')->orPhrase('United Kingdom')->search();
// Search for books that contain either 'United States' or 'United Kingdom', phrases like 'United Emirates' will not be included.

Docs: https://opensearch.pdphilip.com/full-text-search#phrase-search-phrase

agg(array $functions,$field)

Optimization method that allows you to call multiple aggregation functions on a single field in one call. Issue #3
Available aggregation functions: count, avg, min, max, sum, matrix.

Product::where('is_active',true)->agg(['count','avg','min','max','sum'],'sales');

Docs: https://opensearch.pdphilip.com/aggregation#grouped-aggregations

toDsl() (or toSql())

Returns the parsed DSL query from the query builder. Issue #2

Product::whereIn('color', ['red', 'green'])->orderByDesc('sales')->toDsl();

Returns

{
  "index": "products",
  "body": {
    "query": {
      "terms": {
        "color.keyword": [
          "red",
          "green"
        ]
      }
    },
    "_source": [
      "*"
    ],
    "sort": [
      {
        "sales": {
          "order": "desc"
        }
      }
    ]
  }
}

Docs: https://opensearch.pdphilip.com/os-specific#to-dsl


Bug fixes

  • Fixed issue where meta data was being written to indexes in some cases

Upgrades

  • Fixed error tracking index for writing OS errors to a dedicated index - Issue #4
// database.php
'opensearch' => [
  'driver'          => 'opensearch',
  //......
  //......
  //......
  'error_log_index' => env('OS_ERROR_INDEX', false),
],
  • White space code clean-up
'opensearch' => [
    'driver'       => 'opensearch',
    'hosts'        => explode(',', env('OS_HOSTS', 'http://localhost:9200')),
    'basic_auth'   => [
        'username' => env('OS_USERNAME', ''),
        'password' => env('OS_PASSWORD', ''),
    ],
    'sig_v4'       => [
        'provider' => env('OS_SIG_V4_PROVIDER'),
        'region'   => env('OS_SIG_V4_REGION'),
        'service'  => env('OS_SIG_V4_SERVICE'),
    ],
    'ssl'          => [
        'cert'          => env('OS_SSL_CERT', ''),
        'cert_password' => env('OS_SSL_CERT_PASSWORD', ''),
        'key'           => env('OS_SSL_KEY', ''),
        'key_password'  => env('OS_SSL_KEY_PASSWORD', ''),
    ],
    'index_prefix' => env('OS_INDEX_PREFIX', false),
    'options'      => [
        'ssl_verification'    => env('OS_OPT_VERIFY_SSL', true),
        'retires'             => env('OS_OPT_RETRIES'),
        'sniff_on_start'      => env('OS_OPT_SNIFF_ON_START'),
        'port_in_host_header' => env('OS_OPT_PORT_HOST_HEADERS'),
    ],
    'error_log_index' => env('OS_ERROR_INDEX', false),
],
'opensearch_cloud' => [
    'driver'       => 'opensearch',
    'hosts'        => explode(',', env('OS_CLOUD_HOSTS', 'http://localhost:9200')),
    'basic_auth'   => [
        'username' => env('OS_CLOUD_USERNAME', ''),
        'password' => env('OS_CLOUD_PASSWORD', ''),
    ],
    'sig_v4'       => [
        'provider' => env('OS_CLOUD_SIG_V4_PROVIDER'),
        'region'   => env('OS_CLOUD_SIG_V4_REGION'),
        'service'  => env('OS_CLOUD_SIG_V4_SERVICE'),
    ],
    'ssl'          => [
        'cert'          => env('OS_CLOUD_SSL_CERT', ''),
        'cert_password' => env('OS_CLOUD_SSL_CERT_PASSWORD', ''),
        'key'           => env('OS_CLOUD_SSL_KEY', ''),
        'key_password'  => env('OS_CLOUD_SSL_KEY_PASSWORD', ''),
    ],
    'index_prefix' => env('OS_CLOUD_INDEX_PREFIX', false),
    'options'      => [
        'ssl_verification'    => env('OS_CLOUD_OPT_VERIFY_SSL', true),
        'retires'             => env('OS_CLOUD_OPT_RETRIES'),
        'sniff_on_start'      => env('OS_CLOUD_OPT_SNIFF_ON_START'),
        'port_in_host_header' => env('OS_CLOUD_OPT_PORT_HOST_HEADERS'),
    ],
    'error_log_index' => env('OS_CLOUD_ERROR_INDEX', false),
],

v2.0.1

06 Jun 13:19
Compare
Choose a tag to compare

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');
  });

Bug fixes

  • Fixed Connection to process options

Full Changelog: v2.0.0...v2.0.1

v1.0.1

06 Jun 13:19
Compare
Choose a tag to compare

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');
  });

Bug fixes

  • Fixed Connection to process options

Full Changelog: v1.0.0...v1.0.1

v2.0.0

29 Apr 22:38
Compare
Choose a tag to compare

Initial Release for Laravel 10 & 11

composer require pdphilip/elasticsearch:~2

Documentation: https://opensearch.pdphilip.com/

Note: This package has been built off the back of the original Elasticsearch version of this package