Skip to content

Commit

Permalink
Merge #587
Browse files Browse the repository at this point in the history
587: Changes related to the next Meilisearch release (v1.5.0) r=brunoocasali a=meili-bot

Related to this issue: meilisearch/integration-guides#290

This PR:
- gathers the changes related to the next Meilisearch release (v1.5.0) so that this package is ready when the official release is out.
- should pass the tests against the [latest pre-release of Meilisearch](https://github.com/meilisearch/meilisearch/releases).
- might eventually contain test failures until the Meilisearch v1.5.0 is out.

⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.5.0) is out.

_This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/main/resources/pre-release-week.md) purpose._


Co-authored-by: meili-bot <74670311+meili-bot@users.noreply.github.com>
Co-authored-by: Bruno Casali <brunoocasali@gmail.com>
  • Loading branch information
3 people authored Nov 20, 2023
2 parents 18aa00e + b8a0af9 commit e9556dc
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ faceted_search_1: |-
]);
post_dump_1: |-
$client->createDump();
create_snapshot_1: |-
$client->createSnapshot();
phrase_search_1: |-
$client->index('movies')->search('"african american" horror');
sorting_guide_update_sortable_attributes_1: |-
Expand Down
4 changes: 4 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
use Meilisearch\Endpoints\Delegates\HandlesIndex;
use Meilisearch\Endpoints\Delegates\HandlesKeys;
use Meilisearch\Endpoints\Delegates\HandlesMultiSearch;
use Meilisearch\Endpoints\Delegates\HandlesSnapshots;
use Meilisearch\Endpoints\Delegates\HandlesSystem;
use Meilisearch\Endpoints\Delegates\HandlesTasks;
use Meilisearch\Endpoints\Dumps;
use Meilisearch\Endpoints\Health;
use Meilisearch\Endpoints\Indexes;
use Meilisearch\Endpoints\Keys;
use Meilisearch\Endpoints\Snapshots;
use Meilisearch\Endpoints\Stats;
use Meilisearch\Endpoints\Tasks;
use Meilisearch\Endpoints\TenantToken;
Expand All @@ -29,6 +31,7 @@ class Client
use HandlesIndex;
use HandlesTasks;
use HandlesKeys;
use HandlesSnapshots;
use HandlesSystem;
use HandlesMultiSearch;

Expand All @@ -51,6 +54,7 @@ public function __construct(
$this->tasks = new Tasks($this->http);
$this->keys = new Keys($this->http);
$this->dumps = new Dumps($this->http);
$this->snapshots = new Snapshots($this->http);
$this->tenantToken = new TenantToken($this->http, $apiKey);
}
}
17 changes: 17 additions & 0 deletions src/Endpoints/Delegates/HandlesSnapshots.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Meilisearch\Endpoints\Delegates;

use Meilisearch\Endpoints\Snapshots;

trait HandlesSnapshots
{
protected Snapshots $snapshots;

public function createSnapshot(): array
{
return $this->snapshots->create();
}
}
17 changes: 17 additions & 0 deletions src/Endpoints/Snapshots.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Meilisearch\Endpoints;

use Meilisearch\Contracts\Endpoint;

class Snapshots extends Endpoint
{
protected const PATH = '/snapshots';

public function create(): array
{
return $this->http->post(self::PATH);
}
}
2 changes: 1 addition & 1 deletion tests/Endpoints/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ public function testVectorSearch(): void
]);
$this->index->waitForTask($response['taskUid']);

$response = $this->index->search('', ['vector' => [0.5921]]);
$response = $this->index->search('', ['vector' => [1, 0.5921]]);
$hit = $response->getHits()[0];

$this->assertEquals($hit['title'], 'Interestellar');
Expand Down
20 changes: 20 additions & 0 deletions tests/Endpoints/SnapshotsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Tests\Endpoints;

use Tests\TestCase;

final class SnapshotsTest extends TestCase
{
public function testCreateSnapshots(): void
{
$expectedKeys = ['taskUid', 'indexUid', 'status', 'type', 'enqueuedAt'];

$task = $this->client->createSnapshot();

$this->assertSame($expectedKeys, array_keys($task));
$this->assertSame($task['type'], 'snapshotCreation');
}
}

0 comments on commit e9556dc

Please sign in to comment.