Skip to content

Commit

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

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

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

⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.8.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 <[email protected]>
Co-authored-by: Clémentine U. - curqui <[email protected]>
Co-authored-by: curquiza <[email protected]>
Co-authored-by: Bruno Casali <[email protected]>
Co-authored-by: Clémentine <[email protected]>
  • Loading branch information
4 people authored May 6, 2024
2 parents bf9939a + 40a0418 commit aa4dd1c
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ update_settings_1: |-
],
'faceting' => [
'maxValuesPerFacet' => 200
]
],
'searchCutoffMs' => 150
]);
reset_settings_1: |-
$client->index('movies')->resetSettings();
Expand Down Expand Up @@ -707,3 +708,13 @@ update_proximity_precision_settings_1: |-
$client->index('books')->updateProximityPrecision('byAttribute');
reset_proximity_precision_settings_1: |-
$client->index('books')->resetProximityPrecision();
get_search_cutoff_1: |-
$client->index('movies')->getSearchCutoffMs();
update_search_cutoff_1: |-
$client->index('movies')->updateSearchCutoffMs(150);
reset_search_cutoff_1: |-
$client->index('movies')->resetSearchCutoffMs();
negative_search_1: |-
$client->index('movies')->search('-escape');
negative_search_2: |-
$client->index('movies')->search('-"escape"');
17 changes: 17 additions & 0 deletions src/Endpoints/Delegates/HandlesSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,23 @@ public function resetProximityPrecision(): array
return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/proximity-precision');
}

// Settings - searchCutoffMs

public function getSearchCutoffMs(): ?int
{
return $this->http->get(self::PATH.'/'.$this->uid.'/settings/search-cutoff-ms');
}

public function updateSearchCutoffMs(int $value): array
{
return $this->http->put(self::PATH.'/'.$this->uid.'/settings/search-cutoff-ms', $value);
}

public function resetSearchCutoffMs(): array
{
return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/search-cutoff-ms');
}

// Settings - Experimental: Embedders (hybrid search)

public function getEmbedders(): ?array
Expand Down
10 changes: 10 additions & 0 deletions src/Search/SearchResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class SearchResult implements \Countable, \IteratorAggregate
private ?int $hitsCount;
private ?int $offset;
private ?int $limit;
private ?int $semanticHitCount;

private ?int $hitsPerPage;
private ?int $page;
Expand Down Expand Up @@ -65,6 +66,7 @@ public function __construct(array $body)
$this->hitsCount = $body['totalHits'];
}

$this->semanticHitCount = $body['semanticHitCount'] ?? 0;
$this->hits = $body['hits'] ?? [];
$this->processingTimeMs = $body['processingTimeMs'];
$this->query = $body['query'];
Expand Down Expand Up @@ -137,6 +139,14 @@ public function getHitsCount(): int
return $this->hitsCount;
}

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

public function count(): int
{
return $this->hitsCount;
Expand Down
1 change: 1 addition & 0 deletions tests/Endpoints/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ public function testVectorSearch(): void

$response = $index->search('', ['vector' => [1], 'hybrid' => ['semanticRatio' => 1.0]]);

self::assertSame(0, $response->getSemanticHitCount());
self::assertEmpty($response->getHits());
}

Expand Down
3 changes: 3 additions & 0 deletions tests/Settings/EmbeddersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function testUpdateEmbeddersWithOpenAi(): void
$index->waitForTask($promise['taskUid']);

$embedders = $index->getEmbedders();
$embedderConfig['apiKey'] = '<yoXXXXX...';

self::assertSame($embedderConfig, $embedders['myEmbedder']);
}
Expand All @@ -50,6 +51,7 @@ public function testUpdateEmbeddersWithUserProvided(): void
$embedderConfig = [
'source' => 'userProvided',
'dimensions' => 1,
'distribution' => ['mean' => 0.7, 'sigma' => 0.3],
];
$index = $this->createEmptyIndex($this->safeIndexName());

Expand All @@ -69,6 +71,7 @@ public function testUpdateEmbeddersWithHuggingFace(): void
'source' => 'huggingFace',
'model' => 'sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2',
'documentTemplate' => "A movie titled '{{doc.title}}' whose description starts with {{doc.overview|truncatewords: 20}}",
'distribution' => ['mean' => 0.7, 'sigma' => 0.3],
];
$index = $this->createEmptyIndex($this->safeIndexName());

Expand Down
49 changes: 49 additions & 0 deletions tests/Settings/SearchCutoffMsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

namespace Tests\Settings;

use Meilisearch\Endpoints\Indexes;
use Tests\TestCase;

final class SearchCutoffMsTest extends TestCase
{
private Indexes $index;

protected function setUp(): void
{
parent::setUp();
$this->index = $this->createEmptyIndex($this->safeIndexName());
}

public function testGetDefaultSearchCutoffMs(): void
{
$default = $this->index->getSearchCutoffMs();

self::assertNull($default);
}

public function testUpdateSearchCutoffMs(): void
{
$promise = $this->index->updateSearchCutoffMs(50);
$this->assertIsValidPromise($promise);
$this->index->waitForTask($promise['taskUid']);

self::assertSame(50, $this->index->getSearchCutoffMs());
}

public function testResetSearchCutoffMs(): void
{
$promise = $this->index->updateSearchCutoffMs(50);
$this->assertIsValidPromise($promise);
$this->index->waitForTask($promise['taskUid']);

$promise = $this->index->resetSearchCutoffMs();

$this->assertIsValidPromise($promise);
$this->index->waitForTask($promise['taskUid']);

self::assertNull($this->index->getSearchCutoffMs());
}
}

0 comments on commit aa4dd1c

Please sign in to comment.