Skip to content

Add vector query support to the query builder#346

Merged
freost merged 14 commits intomasterfrom
vector-queries
Feb 11, 2026
Merged

Add vector query support to the query builder#346
freost merged 14 commits intomasterfrom
vector-queries

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();

@freost freost merged commit 7c35ea4 into master Feb 11, 2026
4 checks passed
@freost freost deleted the vector-queries branch February 11, 2026 19:49
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