File tree Expand file tree Collapse file tree 4 files changed +51
-1
lines changed
src/Models/Request/CollectionConfig
tests/Unit/Models/Request Expand file tree Collapse file tree 4 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ public function setPayloadM(?int $payloadM): HnswConfig
8080 public function toArray (): array
8181 {
8282 $ data = [];
83- if ($ this ->m ) {
83+ if ($ this ->m !== null ) {
8484 $ data ['m ' ] = $ this ->m ;
8585 }
8686 if ($ this ->efConstruct ) {
Original file line number Diff line number Diff line change @@ -28,6 +28,15 @@ public function testWithM(): void
2828 ], $ config ->toArray ());
2929 }
3030
31+ public function testWithZeroM (): void
32+ {
33+ $ config = (new HnswConfig ())->setM (0 );
34+
35+ $ this ->assertEquals ([
36+ 'm ' => 0
37+ ], $ config ->toArray ());
38+ }
39+
3140 public function testWithInvalidM (): void
3241 {
3342 $ this ->expectException (InvalidArgumentException::class);
Original file line number Diff line number Diff line change @@ -193,6 +193,31 @@ public function testCreateCollectionWithHnswConfig(): void
193193 );
194194 }
195195
196+ public function testCreateCollectionWithHnswConfigAndZeroM (): void
197+ {
198+ $ collection = new CreateCollection ();
199+ $ collection ->addVector (new VectorParams (1024 , VectorParams::DISTANCE_COSINE ));
200+ $ diff = (new HnswConfig ())
201+ ->setM (0 )
202+ ->setPayloadM (1 );
203+
204+ $ collection ->setHnswConfig ($ diff );
205+
206+ $ this ->assertEquals (
207+ [
208+ 'vectors ' => [
209+ 'size ' => '1024 ' ,
210+ 'distance ' => 'Cosine '
211+ ],
212+ 'hnsw_config ' => [
213+ 'm ' => 0 ,
214+ 'payload_m ' => 1 ,
215+ ]
216+ ],
217+ $ collection ->toArray ()
218+ );
219+ }
220+
196221 public function testCreateCollectionWithWalConfig (): void
197222 {
198223 $ collection = new CreateCollection ();
Original file line number Diff line number Diff line change @@ -58,6 +58,22 @@ public function testUpdateCollectionWithHnswConfig(): void
5858 );
5959 }
6060
61+ public function testUpdateCollectionWithHnswConfigAndZeroM (): void
62+ {
63+ $ collection = new UpdateCollection ();
64+ $ collection ->setHnswConfig ((new HnswConfig ())->setM (0 )->setEfConstruct (5 ));
65+
66+ $ this ->assertEquals (
67+ [
68+ 'hnsw_config ' => [
69+ 'm ' => 0 ,
70+ 'ef_construct ' => 5
71+ ],
72+ ],
73+ $ collection ->toArray ()
74+ );
75+ }
76+
6177 public function testUpdateCollectionWithQuantizationConfig (): void
6278 {
6379 $ collection = new UpdateCollection ();
You can’t perform that action at this time.
0 commit comments