Skip to content

Commit e32562f

Browse files
meili-bors[bot]meili-botcurquizabrunoocasali
authored
Merge #631
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]>
2 parents bf9939a + 40a0418 commit e32562f

File tree

6 files changed

+92
-1
lines changed

6 files changed

+92
-1
lines changed

.code-samples.meilisearch.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ update_settings_1: |-
216216
],
217217
'faceting' => [
218218
'maxValuesPerFacet' => 200
219-
]
219+
],
220+
'searchCutoffMs' => 150
220221
]);
221222
reset_settings_1: |-
222223
$client->index('movies')->resetSettings();
@@ -707,3 +708,13 @@ update_proximity_precision_settings_1: |-
707708
$client->index('books')->updateProximityPrecision('byAttribute');
708709
reset_proximity_precision_settings_1: |-
709710
$client->index('books')->resetProximityPrecision();
711+
get_search_cutoff_1: |-
712+
$client->index('movies')->getSearchCutoffMs();
713+
update_search_cutoff_1: |-
714+
$client->index('movies')->updateSearchCutoffMs(150);
715+
reset_search_cutoff_1: |-
716+
$client->index('movies')->resetSearchCutoffMs();
717+
negative_search_1: |-
718+
$client->index('movies')->search('-escape');
719+
negative_search_2: |-
720+
$client->index('movies')->search('-"escape"');

src/Endpoints/Delegates/HandlesSettings.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,23 @@ public function resetProximityPrecision(): array
365365
return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/proximity-precision');
366366
}
367367

368+
// Settings - searchCutoffMs
369+
370+
public function getSearchCutoffMs(): ?int
371+
{
372+
return $this->http->get(self::PATH.'/'.$this->uid.'/settings/search-cutoff-ms');
373+
}
374+
375+
public function updateSearchCutoffMs(int $value): array
376+
{
377+
return $this->http->put(self::PATH.'/'.$this->uid.'/settings/search-cutoff-ms', $value);
378+
}
379+
380+
public function resetSearchCutoffMs(): array
381+
{
382+
return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/search-cutoff-ms');
383+
}
384+
368385
// Settings - Experimental: Embedders (hybrid search)
369386

370387
public function getEmbedders(): ?array

src/Search/SearchResult.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class SearchResult implements \Countable, \IteratorAggregate
2020
private ?int $hitsCount;
2121
private ?int $offset;
2222
private ?int $limit;
23+
private ?int $semanticHitCount;
2324

2425
private ?int $hitsPerPage;
2526
private ?int $page;
@@ -65,6 +66,7 @@ public function __construct(array $body)
6566
$this->hitsCount = $body['totalHits'];
6667
}
6768

69+
$this->semanticHitCount = $body['semanticHitCount'] ?? 0;
6870
$this->hits = $body['hits'] ?? [];
6971
$this->processingTimeMs = $body['processingTimeMs'];
7072
$this->query = $body['query'];
@@ -137,6 +139,14 @@ public function getHitsCount(): int
137139
return $this->hitsCount;
138140
}
139141

142+
/**
143+
* @return non-negative-int
144+
*/
145+
public function getSemanticHitCount(): int
146+
{
147+
return $this->semanticHitCount;
148+
}
149+
140150
public function count(): int
141151
{
142152
return $this->hitsCount;

tests/Endpoints/SearchTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ public function testVectorSearch(): void
700700

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

703+
self::assertSame(0, $response->getSemanticHitCount());
703704
self::assertEmpty($response->getHits());
704705
}
705706

tests/Settings/EmbeddersTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function testUpdateEmbeddersWithOpenAi(): void
4141
$index->waitForTask($promise['taskUid']);
4242

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

4546
self::assertSame($embedderConfig, $embedders['myEmbedder']);
4647
}
@@ -50,6 +51,7 @@ public function testUpdateEmbeddersWithUserProvided(): void
5051
$embedderConfig = [
5152
'source' => 'userProvided',
5253
'dimensions' => 1,
54+
'distribution' => ['mean' => 0.7, 'sigma' => 0.3],
5355
];
5456
$index = $this->createEmptyIndex($this->safeIndexName());
5557

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

tests/Settings/SearchCutoffMsTest.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tests\Settings;
6+
7+
use Meilisearch\Endpoints\Indexes;
8+
use Tests\TestCase;
9+
10+
final class SearchCutoffMsTest extends TestCase
11+
{
12+
private Indexes $index;
13+
14+
protected function setUp(): void
15+
{
16+
parent::setUp();
17+
$this->index = $this->createEmptyIndex($this->safeIndexName());
18+
}
19+
20+
public function testGetDefaultSearchCutoffMs(): void
21+
{
22+
$default = $this->index->getSearchCutoffMs();
23+
24+
self::assertNull($default);
25+
}
26+
27+
public function testUpdateSearchCutoffMs(): void
28+
{
29+
$promise = $this->index->updateSearchCutoffMs(50);
30+
$this->assertIsValidPromise($promise);
31+
$this->index->waitForTask($promise['taskUid']);
32+
33+
self::assertSame(50, $this->index->getSearchCutoffMs());
34+
}
35+
36+
public function testResetSearchCutoffMs(): void
37+
{
38+
$promise = $this->index->updateSearchCutoffMs(50);
39+
$this->assertIsValidPromise($promise);
40+
$this->index->waitForTask($promise['taskUid']);
41+
42+
$promise = $this->index->resetSearchCutoffMs();
43+
44+
$this->assertIsValidPromise($promise);
45+
$this->index->waitForTask($promise['taskUid']);
46+
47+
self::assertNull($this->index->getSearchCutoffMs());
48+
}
49+
}

0 commit comments

Comments
 (0)