Skip to content

Commit f2cb012

Browse files
committed
Improved Doctrine tests [skip ci]
1 parent b53a055 commit f2cb012

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/DoctrineTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ public function testVectorCosineDistance()
115115
$this->assertEquals([1, 2, 3], array_map(fn ($v) => $v->getId(), $neighbors));
116116
}
117117

118+
public function testVectorL1Distance()
119+
{
120+
$this->createItems();
121+
$rsm = new ResultSetMappingBuilder(self::$em);
122+
$rsm->addRootEntityFromClassMetadata('DoctrineItem', 'i');
123+
$neighbors = self::$em->createNativeQuery('SELECT * FROM doctrine_items i ORDER BY embedding <+> ? LIMIT 5', $rsm)
124+
->setParameter(1, new Vector([1, 1, 1]))
125+
->getResult();
126+
$this->assertEquals([1, 3, 2], array_map(fn ($v) => $v->getId(), $neighbors));
127+
}
128+
118129
private function createItems()
119130
{
120131
foreach ([[1, 1, 1], [2, 2, 2], [1, 1, 2]] as $i => $v) {

0 commit comments

Comments
 (0)