Skip to content

Commit c342697

Browse files
meili-bors[bot]meili-botcurquizaManyTheFishbrunoocasali
authored
Merge #683
683: Changes related to the next Meilisearch release (v1.11.0) r=brunoocasali a=meili-bot Related to this issue: meilisearch/integration-guides#303 This PR: - gathers the changes related to the next Meilisearch release (v1.11.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.11.0 is out. ⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.11.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 <[email protected]> Co-authored-by: ManyTheFish <[email protected]> Co-authored-by: Many the fish <[email protected]> Co-authored-by: curquiza <[email protected]> Co-authored-by: Bruno Casali <[email protected]>
2 parents 0d4c933 + fc17a62 commit c342697

12 files changed

+187
-61
lines changed

.code-samples.meilisearch.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,14 @@ search_parameter_reference_retrieve_vectors_1: |-
722722
$client->index('INDEX_NAME')->search('kitchen utensils', [
723723
'retrieveVectors' => true,
724724
'hybrid' => [
725-
'embedder': 'default'
725+
'embedder': 'EMBEDDER_NAME'
726+
]
727+
]);
728+
search_parameter_guide_hybrid_1: |-
729+
$client->index('INDEX_NAME')->search('kitchen utensils', [
730+
'hybrid' => [
731+
'semanticRatio' => 0.9,
732+
'embedder' => 'EMBEDDER_NAME'
726733
]
727734
]);
728735
search_parameter_reference_ranking_score_threshold_1: |-
@@ -742,7 +749,7 @@ distinct_attribute_guide_distinct_parameter_1: |-
742749
search_parameter_guide_matching_strategy_3: |-
743750
$client->index('movies')->search('white shirt', ['matchingStrategy' => 'frequency']);
744751
get_similar_post_1: |-
745-
$similarQuery = new SimilarDocumentsQuery('TARGET_DOCUMENT_ID');
752+
$similarQuery = new SimilarDocumentsQuery('TARGET_DOCUMENT_ID', 'default');
746753
$client->index('INDEX_NAME')->searchSimilarDocuments($similarQuery);
747754
multi_search_federated_1: |-
748755
$client->multiSearch([
@@ -756,7 +763,7 @@ multi_search_federated_1: |-
756763
(new MultiSearchFederation())
757764
);
758765
search_parameter_reference_locales_1: |-
759-
$client->index('INDEX_NAME')->search('進撃の巨人', [
766+
$client->index('INDEX_NAME')->search('QUERY TEXT IN JAPANESE', [
760767
'locales' => ['jpn']
761768
]);
762769
get_localized_attribute_settings_1: |-

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
name: integration-tests (PHP ${{ matrix.php-version }}) (${{ matrix.http-client }})
7070
services:
7171
meilisearch:
72-
image: getmeili/meilisearch:latest
72+
image: getmeili/meilisearch:v1.11.0
7373
ports:
7474
- '7700:7700'
7575
env:

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ services:
1414
- ./:/home/package
1515

1616
meilisearch:
17-
image: getmeili/meilisearch:latest
17+
image: getmeili/meilisearch:v1.10.0
1818
ports:
1919
- "7700"
2020
environment:

phpunit.xml.dist.bak

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
stopOnFailure="false"
9+
cacheResult="false"
10+
colors="true">
11+
<testsuites>
12+
<testsuite name="Tests">
13+
<directory suffix="Test.php">./tests</directory>
14+
</testsuite>
15+
</testsuites>
16+
<coverage>
17+
<include>
18+
<directory>src/</directory>
19+
</include>
20+
</coverage>
21+
<php>
22+
<env name="MEILISEARCH_URL" value="http://localhost:7700"/>
23+
<env name="MEILISEARCH_API_KEY" value="masterKey"/>
24+
</php>
25+
</phpunit>

src/Contracts/MultiSearchFederation.php

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ class MultiSearchFederation
1616
*/
1717
private ?int $offset = null;
1818

19+
/**
20+
* @var array<non-empty-string, list<non-empty-string>>|null
21+
*/
22+
private ?array $facetsByIndex = null;
23+
24+
/**
25+
* @var array{maxValuesPerFacet: positive-int}|null
26+
*/
27+
private ?array $mergeFacets = null;
28+
1929
/**
2030
* @param non-negative-int $limit
2131
*
@@ -40,17 +50,45 @@ public function setOffset(int $offset): self
4050
return $this;
4151
}
4252

53+
/**
54+
* @param array<non-empty-string, list<non-empty-string>> $facetsByIndex
55+
*
56+
* @return $this
57+
*/
58+
public function setFacetsByIndex(array $facetsByIndex): self
59+
{
60+
$this->facetsByIndex = $facetsByIndex;
61+
62+
return $this;
63+
}
64+
65+
/**
66+
* @param array{maxValuesPerFacet: positive-int} $mergeFacets
67+
*
68+
* @return $this
69+
*/
70+
public function setMergeFacets(array $mergeFacets): self
71+
{
72+
$this->mergeFacets = $mergeFacets;
73+
74+
return $this;
75+
}
76+
4377
/**
4478
* @return array{
4579
* limit?: non-negative-int,
46-
* offset?: non-negative-int
80+
* offset?: non-negative-int,
81+
* facetsByIndex?: array<non-empty-string, list<non-empty-string>>,
82+
* mergeFacets?: array{maxValuesPerFacet: positive-int},
4783
* }
4884
*/
4985
public function toArray(): array
5086
{
5187
return array_filter([
5288
'limit' => $this->limit,
5389
'offset' => $this->offset,
90+
'facetsByIndex' => $this->facetsByIndex,
91+
'mergeFacets' => $this->mergeFacets,
5492
], static function ($item) { return null !== $item; });
5593
}
5694
}

src/Contracts/SimilarDocumentsQuery.php

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ class SimilarDocumentsQuery
1111
*/
1212
private $id;
1313

14+
/**
15+
* @var non-empty-string
16+
*/
17+
private string $embedder;
18+
1419
/**
1520
* @var non-negative-int|null
1621
*/
@@ -21,11 +26,6 @@ class SimilarDocumentsQuery
2126
*/
2227
private ?int $limit = null;
2328

24-
/**
25-
* @var non-empty-string|null
26-
*/
27-
private ?string $embedder = null;
28-
2929
/**
3030
* @var list<non-empty-string>|null
3131
*/
@@ -48,11 +48,13 @@ class SimilarDocumentsQuery
4848
private $rankingScoreThreshold;
4949

5050
/**
51-
* @param int|string $id
51+
* @param int|string $id
52+
* @param non-empty-string $embedder
5253
*/
53-
public function __construct($id)
54+
public function __construct($id, string $embedder)
5455
{
5556
$this->id = $id;
57+
$this->embedder = $embedder;
5658
}
5759

5860
/**
@@ -91,18 +93,6 @@ public function setFilter(array $filter): self
9193
return $this;
9294
}
9395

94-
/**
95-
* @param non-empty-string $embedder
96-
*
97-
* @return $this
98-
*/
99-
public function setEmbedder(string $embedder): self
100-
{
101-
$this->embedder = $embedder;
102-
103-
return $this;
104-
}
105-
10696
/**
10797
* @param list<non-empty-string> $attributesToRetrieve an array of attribute names to retrieve
10898
*
@@ -166,10 +156,10 @@ public function setRankingScoreThreshold($rankingScoreThreshold): self
166156
/**
167157
* @return array{
168158
* id: int|string,
159+
* embedder: non-empty-string,
169160
* offset?: non-negative-int,
170161
* limit?: positive-int,
171162
* filter?: array<int, array<int, string>|string>,
172-
* embedder?: non-empty-string,
173163
* attributesToRetrieve?: list<non-empty-string>,
174164
* showRankingScore?: bool,
175165
* showRankingScoreDetails?: bool,
@@ -181,10 +171,10 @@ public function toArray(): array
181171
{
182172
return array_filter([
183173
'id' => $this->id,
174+
'embedder' => $this->embedder,
184175
'offset' => $this->offset,
185176
'limit' => $this->limit,
186177
'filter' => $this->filter,
187-
'embedder' => $this->embedder,
188178
'attributesToRetrieve' => $this->attributesToRetrieve,
189179
'showRankingScore' => $this->showRankingScore,
190180
'showRankingScoreDetails' => $this->showRankingScoreDetails,

tests/Contracts/MultiSearchFederationTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,18 @@ public function testSetOffset(): void
2929

3030
self::assertSame(['offset' => 5], $data->toArray());
3131
}
32+
33+
public function testSetFacetsByIndex(): void
34+
{
35+
$data = (new MultiSearchFederation())->setFacetsByIndex(['books' => ['author', 'genre']]);
36+
37+
self::assertSame(['facetsByIndex' => ['books' => ['author', 'genre']]], $data->toArray());
38+
}
39+
40+
public function testSetMergeFacets(): void
41+
{
42+
$data = (new MultiSearchFederation())->setMergeFacets(['maxValuesPerFacet' => 10]);
43+
44+
self::assertSame(['mergeFacets' => ['maxValuesPerFacet' => 10]], $data->toArray());
45+
}
3246
}

tests/Contracts/SimilarDocumentsQueryTest.php

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,54 +10,48 @@
1010
final class SimilarDocumentsQueryTest extends TestCase
1111
{
1212
/**
13-
* @param int|string $id
13+
* @param int|string $id
14+
* @param non-empty-string $embedder
1415
*
15-
* @testWith [123]
16-
* ["test"]
16+
* @testWith [123, "default"]
17+
* ["test", "manual"]
1718
*/
18-
public function testConstruct($id): void
19+
public function testConstruct($id, string $embedder): void
1920
{
20-
$data = new SimilarDocumentsQuery($id);
21+
$data = new SimilarDocumentsQuery($id, $embedder);
2122

22-
self::assertSame(['id' => $id], $data->toArray());
23+
self::assertSame(['id' => $id, 'embedder' => $embedder], $data->toArray());
2324
}
2425

2526
public function testSetOffset(): void
2627
{
27-
$data = (new SimilarDocumentsQuery('test'))->setOffset(66);
28+
$data = (new SimilarDocumentsQuery('test', 'default'))->setOffset(66);
2829

29-
self::assertSame(['id' => 'test', 'offset' => 66], $data->toArray());
30+
self::assertSame(['id' => 'test', 'embedder' => 'default', 'offset' => 66], $data->toArray());
3031
}
3132

3233
public function testSetLimit(): void
3334
{
34-
$data = (new SimilarDocumentsQuery('test'))->setLimit(50);
35+
$data = (new SimilarDocumentsQuery('test', 'default'))->setLimit(50);
3536

36-
self::assertSame(['id' => 'test', 'limit' => 50], $data->toArray());
37+
self::assertSame(['id' => 'test', 'embedder' => 'default', 'limit' => 50], $data->toArray());
3738
}
3839

3940
public function testSetFilter(): void
4041
{
41-
$data = (new SimilarDocumentsQuery('test'))->setFilter([
42+
$data = (new SimilarDocumentsQuery('test', 'default'))->setFilter([
4243
['genres = horror', 'genres = mystery'],
4344
"director = 'Jordan Peele'",
4445
]);
4546

46-
self::assertSame(['id' => 'test', 'filter' => [['genres = horror', 'genres = mystery'], "director = 'Jordan Peele'"]], $data->toArray());
47-
}
48-
49-
public function testSetEmbedder(): void
50-
{
51-
$data = (new SimilarDocumentsQuery('test'))->setEmbedder('default');
52-
53-
self::assertSame(['id' => 'test', 'embedder' => 'default'], $data->toArray());
47+
self::assertSame(['id' => 'test', 'embedder' => 'default', 'filter' => [['genres = horror', 'genres = mystery'], "director = 'Jordan Peele'"]], $data->toArray());
5448
}
5549

5650
public function testSetAttributesToRetrieve(): void
5751
{
58-
$data = (new SimilarDocumentsQuery('test'))->setAttributesToRetrieve(['name', 'price']);
52+
$data = (new SimilarDocumentsQuery('test', 'default'))->setAttributesToRetrieve(['name', 'price']);
5953

60-
self::assertSame(['id' => 'test', 'attributesToRetrieve' => ['name', 'price']], $data->toArray());
54+
self::assertSame(['id' => 'test', 'embedder' => 'default', 'attributesToRetrieve' => ['name', 'price']], $data->toArray());
6155
}
6256

6357
/**
@@ -66,9 +60,9 @@ public function testSetAttributesToRetrieve(): void
6660
*/
6761
public function testSetShowRankingScore(bool $showRankingScore): void
6862
{
69-
$data = (new SimilarDocumentsQuery('test'))->setShowRankingScore($showRankingScore);
63+
$data = (new SimilarDocumentsQuery('test', 'default'))->setShowRankingScore($showRankingScore);
7064

71-
self::assertSame(['id' => 'test', 'showRankingScore' => $showRankingScore], $data->toArray());
65+
self::assertSame(['id' => 'test', 'embedder' => 'default', 'showRankingScore' => $showRankingScore], $data->toArray());
7266
}
7367

7468
/**
@@ -77,9 +71,9 @@ public function testSetShowRankingScore(bool $showRankingScore): void
7771
*/
7872
public function testSetShowRankingScoreDetails(bool $showRankingScoreDetails): void
7973
{
80-
$data = (new SimilarDocumentsQuery('test'))->setShowRankingScoreDetails($showRankingScoreDetails);
74+
$data = (new SimilarDocumentsQuery('test', 'default'))->setShowRankingScoreDetails($showRankingScoreDetails);
8175

82-
self::assertSame(['id' => 'test', 'showRankingScoreDetails' => $showRankingScoreDetails], $data->toArray());
76+
self::assertSame(['id' => 'test', 'embedder' => 'default', 'showRankingScoreDetails' => $showRankingScoreDetails], $data->toArray());
8377
}
8478

8579
/**
@@ -88,9 +82,9 @@ public function testSetShowRankingScoreDetails(bool $showRankingScoreDetails): v
8882
*/
8983
public function testSetRetrieveVectors(bool $retrieveVectors): void
9084
{
91-
$data = (new SimilarDocumentsQuery('test'))->setRetrieveVectors($retrieveVectors);
85+
$data = (new SimilarDocumentsQuery('test', 'default'))->setRetrieveVectors($retrieveVectors);
9286

93-
self::assertSame(['id' => 'test', 'retrieveVectors' => $retrieveVectors], $data->toArray());
87+
self::assertSame(['id' => 'test', 'embedder' => 'default', 'retrieveVectors' => $retrieveVectors], $data->toArray());
9488
}
9589

9690
/**
@@ -101,8 +95,8 @@ public function testSetRetrieveVectors(bool $retrieveVectors): void
10195
*/
10296
public function testSetRankingScoreThreshold($rankingScoreThreshold): void
10397
{
104-
$data = (new SimilarDocumentsQuery('test'))->setRankingScoreThreshold($rankingScoreThreshold);
98+
$data = (new SimilarDocumentsQuery('test', 'default'))->setRankingScoreThreshold($rankingScoreThreshold);
10599

106-
self::assertSame(['id' => 'test', 'rankingScoreThreshold' => $rankingScoreThreshold], $data->toArray());
100+
self::assertSame(['id' => 'test', 'embedder' => 'default', 'rankingScoreThreshold' => $rankingScoreThreshold], $data->toArray());
107101
}
108102
}

tests/Endpoints/MultiSearchTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,15 @@ public function testFederation(): void
8989
// By setting the weight to 0.9 this query should appear second
9090
->setFederationOptions((new FederationOptions())->setWeight(0.9)),
9191
],
92-
(new MultiSearchFederation())->setLimit(2)
92+
(new MultiSearchFederation())->setLimit(2)->setFacetsByIndex([$this->booksIndex->getUid() => ['genre'], $this->songsIndex->getUid() => ['duration-float']])->setMergeFacets(['maxValuesPerFacet' => 10])
9393
);
9494

9595
self::assertArrayHasKey('hits', $response);
9696
self::assertArrayHasKey('processingTimeMs', $response);
9797
self::assertArrayHasKey('limit', $response);
9898
self::assertArrayHasKey('offset', $response);
9999
self::assertArrayHasKey('estimatedTotalHits', $response);
100+
self::assertArrayHasKey('facetDistribution', $response);
100101
self::assertCount(2, $response['hits']);
101102
self::assertSame(2, $response['limit']);
102103
self::assertSame(0, $response['offset']);

tests/Endpoints/SearchTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,12 +701,12 @@ public function testVectorSearch(): void
701701
$this->assertIsValidPromise($promise);
702702
$index->waitForTask($promise['taskUid']);
703703

704-
$response = $index->search('', ['vector' => [-0.5, 0.3, 0.85], 'hybrid' => ['semanticRatio' => 1.0]]);
704+
$response = $index->search('', ['vector' => [-0.5, 0.3, 0.85], 'hybrid' => ['semanticRatio' => 1.0, 'embedder' => 'manual']]);
705705

706706
self::assertSame(5, $response->getSemanticHitCount());
707707
self::assertArrayNotHasKey('_vectors', $response->getHit(0));
708708

709-
$response = $index->search('', ['vector' => [-0.5, 0.3, 0.85], 'hybrid' => ['semanticRatio' => 1.0], 'retrieveVectors' => true]);
709+
$response = $index->search('', ['vector' => [-0.5, 0.3, 0.85], 'hybrid' => ['semanticRatio' => 1.0, 'embedder' => 'manual'], 'retrieveVectors' => true]);
710710

711711
self::assertSame(5, $response->getSemanticHitCount());
712712
self::assertArrayHasKey('_vectors', $response->getHit(0));

0 commit comments

Comments
 (0)