Skip to content

Conversation

@freost
Copy link
Member

@freost freost commented Feb 9, 2026

Type


Yes/No
Bugfix? -
New feature? Yes
Other? -

Additional information

Yes/No
Has backwards compatibility breaks? No
Has unit and/or integration tests? Yes

Description


This PR adds vector query support to the query builder for the following databases:

  • MariaDB
  • MySQL (HeatWave)
  • Postgres (pgvector)

Inserting vectors

$query = $query
->table('foobar')
->insert([
    'embedding' => new Vector([1, 2, 3, 4, 5])
]);

Selecting vectors

$query = $query
->table('foobar')
->select([
    new Vector('embedding')->as('vector')
]);

Selecting vector distances (cosine or euclidean)

$query = $query
->table('foobar')
->select([
    new VectorDistance('embedding', [1, 2, 3, 4, 5])->as('distance')
]);

Filtering on vector distance (cosine or euclidean)

$query = $query
->table('foobar')
->whereVectorDistance('embedding', [1, 2, 3, 4, 5], maxDistance: 0.15)
->limit(10)
->all();

Sorting by vector distance (cosine or euclidean)

$query = $query
->table('foobar')
->orderByVectorDistance('embedding', [1, 2, 3, 4, 5])
->limit(10)
->all();

$query = $query
->table('foobar')
->ascendingVectorDistance('embedding', [1, 2, 3, 4, 5])
->limit(10)
->all();

$query = $query
->table('foobar')
->descendingVectorDistance('embedding', [1, 2, 3, 4, 5])
->limit(10)
->all();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant