Skip to content

feat: native vector search support - #130

Open
rebasedming wants to merge 2 commits into
paradedb-amfrom
vector-search
Open

feat: native vector search support#130
rebasedming wants to merge 2 commits into
paradedb-amfrom
vector-search

Conversation

@rebasedming

Copy link
Copy Markdown
Contributor

What

Implements paradedb/paradedb#5685: native vector search support with no neighbor gem dependency.

  • vector(n) ActiveModel type with t.vector :embedding, limit: n migration DSL and schema-dumper round-trip
  • Model.nearest(:embedding, vec).limit(k) — orders by the pgvector operator, defaults the metric from the index opclass, and auto-adds key_field @@@ pdb.all() when the relation has no ParadeDB predicate
  • Arel builder/predication distance helpers (<->, <=>, <#>)
  • Vector fields in the bm25 index DSL via embedding: { metric: :cosine }, emitted as opclasses and round-tripped by the schema dumper
  • hybrid_rrf example migrated off neighbor; new vector_search example; vector integration tests capability-gated until a release ships vector-in-bm25

Why

ParadeDB indexes pgvector columns inside the bm25 index, so users should get the full query surface from this gem alone.

Tests

Rails 8.1 and 7.2: 387 unit / 289 integration examples, 0 failures (2 pending vs 0.24.2 via capability gate; 0 pending vs a dev pg_search 0.25.0 where EXPLAIN confirms Top-K pushdown). rubocop/api-coverage/gem-install smoke all clean.

@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.34711% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.83%. Comparing base (afe980b) to head (d47a2ae).

Files with missing lines Patch % Lines
lib/parade_db/vector.rb 96.96% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##           paradedb-am     #130      +/-   ##
===============================================
+ Coverage        90.43%   90.83%   +0.40%     
===============================================
  Files               20       21       +1     
  Lines             2425     2542     +117     
  Branches           779      811      +32     
===============================================
+ Hits              2193     2309     +116     
- Misses             232      233       +1     
Flag Coverage Δ
rails-paradedb 90.83% <98.34%> (+0.40%) ⬆️
rb3.2 91.09% <98.33%> (+0.38%) ⬆️
rb3.3 91.09% <98.33%> (+0.38%) ⬆️
rb3.4 90.83% <98.34%> (+0.40%) ⬆️
rb4.0 82.61% <95.04%> (+0.63%) ⬆️
rl7.2 90.83% <98.34%> (+0.40%) ⬆️
rl8.1 82.61% <95.04%> (+0.63%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
lib/parade_db.rb 98.14% <100.00%> (+0.03%) ⬆️
lib/parade_db/arel/builder.rb 94.42% <100.00%> (+0.23%) ⬆️
lib/parade_db/arel/predications.rb 97.77% <100.00%> (+0.13%) ⬆️
lib/parade_db/index.rb 90.50% <100.00%> (+0.44%) ⬆️
lib/parade_db/migration_helpers.rb 84.91% <100.00%> (+0.20%) ⬆️
lib/parade_db/model.rb 84.31% <100.00%> (+1.09%) ⬆️
lib/parade_db/search_methods.rb 94.23% <100.00%> (+0.10%) ⬆️
lib/parade_db/vector.rb 96.96% <96.96%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread examples/hybrid_rrf/hybrid_rrf.rb Outdated
puts "Hybrid Search with Reciprocal Rank Fusion (single SQL query)"
puts "=" * 80
puts "\nCombining ParadeDB DSL + Neighbor DSL in one CTE-based query"
puts "\nCombining ParadeDB BM25 + native vector distance in one CTE-based query"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
puts "\nCombining ParadeDB BM25 + native vector distance in one CTE-based query"
puts "\nCombining ParadeDB BM25 + vector distance in one CTE-based query"

Wdyt?

Comment thread README.md
- [Autocomplete](examples/autocomplete/autocomplete.rb)
- [More Like This](examples/more_like_this/more_like_this.rb)
- [Hybrid Search (RRF)](examples/hybrid_rrf/hybrid_rrf.rb)
- [Vector Search](examples/vector_search/vector_search.rb)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps vector search should be higher? Like right below Quickstart maybe, on all ORMs?

Comment thread README.md Outdated

## Vector Search

rails-paradedb natively supports pgvector `vector(n)` columns — no `neighbor` or other pgvector gem required. Declare the column, list it in the BM25 index with a distance metric, and run Top-K queries:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment on EF Core PR

@rebasedming
rebasedming changed the base branch from main to paradedb-am July 27, 2026 15:34
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.

2 participants