Skip to content

Commit

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

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

This PR:
- gathers the changes related to the next Meilisearch release (v1.12.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.12.0 is out.

⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.12.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._


705: Update version for the next release (v1.12.0) r=curquiza a=meili-bot

_This PR is auto-generated._

The automated script updates the version of meilisearch-php to a new version: "v1.12.0"

CHANGELOGS 👇

This version introduces features released on Meilisearch v1.12.0 🎉

Check out the [Meilisearch v1.12.0 changelog](https://github.com/meilisearch/meilisearch/releases/tag/v1.12.0) for more information.

## 🚀 Enhancements

- **Addition:** #699

Introducing new methods to get one or several batches, respectively `getBatch()` and `getBatches()`. A batch is a set of tasks processed together.

- **Addition:** #698

The `TaskQuery` class now has a `setReverse()` method to retrieve tasks in reverse chronological order.

```php
client->getTasks((new TasksQuery())->setReverse(true));
```

- **Addition:** #702

Index settings now allow disabling **prefix search** and **facet search**. They're both enabled by default. The SDK now comes with dedicated methods to configure these settings.

```php
// disable prefix search
$index->updatePrefixSearch('disabled');
// reset prefix search settings
$index->resetPrefixSearch();

// disable facet search
$index->updateFacetSearch(false);
// reset facet search settings
$index->resetFacetSearch();
```

## 🐛 Bug Fixes

- fix: pull the latest in the CI instead of forcing the v1.11 (#691) `@/mdubus`
- Make `hitsCount` always the number of `hits` (and not `totalHits` value) (#701) `@/johnnynotsolucky`

## ⚙️ Maintenance/misc

- Update CI to run with PHP 8.4 (#696) `@/norkunas`
- Fixed SearchNestedFieldsTest test (#704) `@/aivchen`
- PHPStan 2 + fixed uninitialized properties in SearchResult (#706) `@/aivchen`

Thanks again to `@/aivchen,` `@/johnnynotsolucky,` `@/mdubus,` `@/norkunas,` Andrei Ivchenkov, and `@/Strift!` 🎉

Co-authored-by: meili-bot <[email protected]>
Co-authored-by: Clémentine <[email protected]>
Co-authored-by: Strift <[email protected]>
Co-authored-by: Laurent Cazanove <[email protected]>
  • Loading branch information
4 people authored Dec 23, 2024
3 parents 20f68c7 + 1e5ac8e + aa06a3d commit 6515ed6
Show file tree
Hide file tree
Showing 15 changed files with 541 additions and 4 deletions.
18 changes: 17 additions & 1 deletion .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ update_displayed_attributes_1: |-
]);
reset_displayed_attributes_1: |-
$client->index('movies')->resetDisplayedAttributes();
get_typo_tolerance_1:
get_typo_tolerance_1: |-
$client->index('books')->getTypoTolerance();
update_typo_tolerance_1: |-
$client->index('books')->updateTypoTolerance([
Expand Down Expand Up @@ -775,3 +775,19 @@ update_localized_attribute_settings_1: |-
]);
reset_localized_attribute_settings_1: |-
$client->index('INDEX_NAME')->resetLocalizedAttributes();
get_facet_search_settings_1: |-
$client->index('INDEX_NAME')->getFacetSearch();
update_facet_search_settings_1: |-
$client->index('INDEX_NAME')->updateFacetSearch(false);
reset_facet_search_settings_1: |-
$client->index('INDEX_NAME')->resetFacetSearch();
get_prefix_search_settings_1: |-
$client->index('INDEX_NAME')->getPrefixSearch();
update_prefix_search_settings_1: |-
$client->index('INDEX_NAME')->updatePrefixSearch('disabled');
reset_prefix_search_settings_1: |-
$client->index('INDEX_NAME')->resetPrefixSearch();
get_all_batches_1: |-
$client->getBatches();
get_batch_1: |-
$client->getBatch(BATCH_UID);
4 changes: 4 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Meilisearch;

use Meilisearch\Endpoints\Batches;
use Meilisearch\Endpoints\Delegates\HandlesBatches;
use Meilisearch\Endpoints\Delegates\HandlesDumps;
use Meilisearch\Endpoints\Delegates\HandlesIndex;
use Meilisearch\Endpoints\Delegates\HandlesKeys;
Expand Down Expand Up @@ -34,6 +36,7 @@ class Client
use HandlesSnapshots;
use HandlesSystem;
use HandlesMultiSearch;
use HandlesBatches;

/**
* @param array<int, string> $clientAgents
Expand All @@ -52,6 +55,7 @@ public function __construct(
$this->version = new Version($this->http);
$this->stats = new Stats($this->http);
$this->tasks = new Tasks($this->http);
$this->batches = new Batches($this->http);
$this->keys = new Keys($this->http);
$this->dumps = new Dumps($this->http);
$this->snapshots = new Snapshots($this->http);
Expand Down
68 changes: 68 additions & 0 deletions src/Contracts/BatchesQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

declare(strict_types=1);

namespace Meilisearch\Contracts;

use Meilisearch\Endpoints\Delegates\TasksQueryTrait;

class BatchesQuery
{
use TasksQueryTrait;

private ?int $from = null;

/**
* @var non-negative-int|null
*/
private ?int $limit = null;

private ?bool $reverse = null;

/**
* @return $this
*/
public function setFrom(int $from): self
{
$this->from = $from;

return $this;
}

/**
* @return $this
*/
public function setLimit(int $limit): self
{
$this->limit = $limit;

return $this;
}

/**
* @return $this
*/
public function setReverse(bool $reverse): self
{
$this->reverse = $reverse;

return $this;
}

public function toArray(): array
{
return array_filter(
array_merge(
$this->baseArray(),
[
'from' => $this->from,
'limit' => $this->limit,
'reverse' => (null !== $this->reverse ? ($this->reverse ? 'true' : 'false') : null),
]
),
static function ($item) {
return null !== $item;
}
);
}
}
94 changes: 94 additions & 0 deletions src/Contracts/BatchesResults.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

declare(strict_types=1);

namespace Meilisearch\Contracts;

class BatchesResults extends Data
{
/**
* @var non-negative-int
*/
private int $next;

/**
* @var non-negative-int
*/
private int $limit;

/**
* @var non-negative-int
*/
private int $from;

/**
* @var non-negative-int
*/
private int $total;

public function __construct(array $params)
{
parent::__construct($params['results']);

$this->from = $params['from'] ?? 0;
$this->limit = $params['limit'] ?? 0;
$this->next = $params['next'] ?? 0;
$this->total = $params['total'] ?? 0;
}

/**
* @return array<int, array>
*/
public function getResults(): array
{
return $this->data;
}

/**
* @return non-negative-int
*/
public function getNext(): int
{
return $this->next;
}

/**
* @return non-negative-int
*/
public function getLimit(): int
{
return $this->limit;
}

/**
* @return non-negative-int
*/
public function getFrom(): int
{
return $this->from;
}

/**
* @return non-negative-int
*/
public function getTotal(): int
{
return $this->total;
}

public function toArray(): array
{
return [
'results' => $this->data,
'next' => $this->next,
'limit' => $this->limit,
'from' => $this->from,
'total' => $this->total,
];
}

public function count(): int
{
return \count($this->data);
}
}
28 changes: 27 additions & 1 deletion src/Contracts/TasksQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class TasksQuery
*/
private ?array $canceledBy = null;

private ?int $batchUid = null;

private ?bool $reverse = null;

/**
* @return $this
*/
Expand Down Expand Up @@ -54,6 +58,23 @@ public function setLimit(int $limit): self
return $this;
}

/**
* @return $this
*/
public function setBatchUid(int $batchUid): self
{
$this->batchUid = $batchUid;

return $this;
}

public function setReverse(bool $reverse): self
{
$this->reverse = $reverse;

return $this;
}

public function toArray(): array
{
return array_filter(
Expand All @@ -63,8 +84,13 @@ public function toArray(): array
'from' => $this->from,
'limit' => $this->limit,
'canceledBy' => $this->formatArray($this->canceledBy),
'batchUid' => $this->batchUid,
'reverse' => (null !== $this->reverse ? ($this->reverse ? 'true' : 'false') : null),
]
), static function ($item) { return null !== $item; }
),
static function ($item) {
return null !== $item;
}
);
}
}
22 changes: 22 additions & 0 deletions src/Endpoints/Batches.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace Meilisearch\Endpoints;

use Meilisearch\Contracts\Endpoint;

class Batches extends Endpoint
{
protected const PATH = '/batches';

public function get($batchUid): array
{
return $this->http->get(self::PATH.'/'.$batchUid);
}

public function all(array $query = []): array
{
return $this->http->get(self::PATH.'/', $query);
}
}
28 changes: 28 additions & 0 deletions src/Endpoints/Delegates/HandlesBatches.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Meilisearch\Endpoints\Delegates;

use Meilisearch\Contracts\BatchesQuery;
use Meilisearch\Contracts\BatchesResults;
use Meilisearch\Endpoints\Batches;

trait HandlesBatches
{
protected Batches $batches;

public function getBatch($uid): array
{
return $this->batches->get($uid);
}

public function getBatches(?BatchesQuery $options = null): BatchesResults
{
$query = null !== $options ? $options->toArray() : [];

$response = $this->batches->all($query);

return new BatchesResults($response);
}
}
56 changes: 56 additions & 0 deletions src/Endpoints/Delegates/HandlesSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,4 +421,60 @@ public function resetEmbedders(): array
{
return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/embedders');
}

// Settings - Facet Search

/**
* @since Meilisearch v1.12.0
*/
public function getFacetSearch(): bool
{
return $this->http->get(self::PATH.'/'.$this->uid.'/settings/facet-search');
}

/**
* @since Meilisearch v1.12.0
*/
public function updateFacetSearch(bool $facetSearch): array
{
return $this->http->put(self::PATH.'/'.$this->uid.'/settings/facet-search', $facetSearch);
}

/**
* @since Meilisearch v1.12.0
*/
public function resetFacetSearch(): array
{
return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/facet-search');
}

// Settings - Prefix Search

/**
* @return 'indexingTime'|'disabled'
*
* @since Meilisearch v1.12.0
*/
public function getPrefixSearch(): string
{
return $this->http->get(self::PATH.'/'.$this->uid.'/settings/prefix-search');
}

/**
* @param 'indexingTime'|'disabled' $prefixSearch
*
* @since Meilisearch v1.12.0
*/
public function updatePrefixSearch(string $prefixSearch): array
{
return $this->http->put(self::PATH.'/'.$this->uid.'/settings/prefix-search', $prefixSearch);
}

/**
* @since Meilisearch v1.12.0
*/
public function resetPrefixSearch(): array
{
return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/prefix-search');
}
}
2 changes: 1 addition & 1 deletion src/Meilisearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Meilisearch
{
public const VERSION = '1.11.0';
public const VERSION = '1.12.0';

/**
* @return non-empty-string
Expand Down
Loading

0 comments on commit 6515ed6

Please sign in to comment.