Skip to content

feat: Add lance_search support for {vector,full-text,fuzzy} search#45

Merged
Xuanwo merged 2 commits intomainfrom
xuanwo/sql-search
Dec 24, 2025
Merged

feat: Add lance_search support for {vector,full-text,fuzzy} search#45
Xuanwo merged 2 commits intomainfrom
xuanwo/sql-search

Conversation

@Xuanwo
Copy link
Copy Markdown
Collaborator

@Xuanwo Xuanwo commented Dec 24, 2025

This PR will add lance_search support for {vector,full-text,fuzzy} search.

Close #44

Full-text search (FTS)

-- Search a text column, returning BM25-like scores in `_score`
SELECT id, text, _score
FROM lance_search('path/to/dataset.lance', 'puppy', text_column = 'text', k = 10, prefilter = true)
ORDER BY _score DESC;

Structured text queries

-- Equivalent to the plain string form, but explicit about the target column
SELECT id, text, _score
FROM lance_search('path/to/dataset.lance', lance_match_query('crazily', 'text'), k = 100)
ORDER BY _score DESC;

Vector search

-- Search a vector column, returning distances in `_distance` (smaller is closer)
SELECT id, label, _distance
FROM lance_search(
  'path/to/dataset.lance',
  [0.1, 0.2, 0.3, 0.4]::FLOAT[],
  vector_column = 'vec',
  k = 5,
  prefilter = true
)
ORDER BY _distance ASC;

Hybrid search (vector + FTS)

-- Combine vector and text scores, returning `_hybrid_score` in addition to `_distance` / `_score`
SELECT id, _hybrid_score, _distance, _score
FROM lance_search(
  'path/to/dataset.lance',
  lance_hybrid_query([0.1, 0.2, 0.3, 0.4]::FLOAT[], 'puppy', 'vec', 'text', 0.5, 4),
  k = 10,
  prefilter = false
)
ORDER BY _hybrid_score DESC;

Parts of this PR were drafted with assistance from Codex (with gpt-5.2) and fully reviewed and edited by me. I take full responsibility for all changes.

@Xuanwo Xuanwo merged commit 80faeb0 into main Dec 24, 2025
9 checks passed
@Xuanwo Xuanwo deleted the xuanwo/sql-search branch December 24, 2025 13:30
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.

Add support for lance_search

1 participant