Skip to content

Commit 9b3c755

Browse files
committed
feat: add paradedb-named aliases for bm25-named API (paradedb/paradedb#5706)
1 parent 449e4e7 commit 9b3c755

6 files changed

Lines changed: 38 additions & 9 deletions

File tree

paradedb-demo/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Exercises:
1313
- `CREATE EXTENSION pg_search` / `vector` via the docker init scripts (`init/*.sql`).
1414
- Automatic `CREATE INDEX ... USING bm25 (...) WITH (key_field='...')` via upstream's index-type registry. The contract uses `type: 'bm25'` so the migration also runs on released servers (<= 0.24.3); on pg_search 0.25.0+ (unreleased) `type: 'paradedb'` emits `USING paradedb`, the primary access method name. The gated test in `test/bm25.integration.test.ts` exercises the `paradedb` AM when the server registers it.
1515

16-
The index covers the text columns only: released pg_search builds reject vector columns in ParadeDB indexes (requires pg_search 0.25.0+, unreleased; paradedb/paradedb#5685), so vector Top-K runs unaccelerated here. The gated integration test in `test/vector.integration.test.ts` probes which access method carries the vector opclasses, exercises the vector-in-index DDL (via `renderBm25IndexDdl`) against it, and skips with a clear reason on released builds.
16+
The index covers the text columns only: released pg_search builds reject vector columns in ParadeDB indexes (requires pg_search 0.25.0+, unreleased; paradedb/paradedb#5685), so vector Top-K runs unaccelerated here. The gated integration test in `test/vector.integration.test.ts` probes which access method carries the vector opclasses, exercises the vector-in-index DDL (via `renderParadeDbIndexDdl`) against it, and skips with a clear reason on released builds.
1717

1818
## Run it
1919

paradedb-demo/test/vector.integration.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'dotenv/config';
2-
import { renderBm25IndexDdl } from '@prisma-next/extension-paradedb/ddl';
2+
import { renderParadeDbIndexDdl } from '@prisma-next/extension-paradedb/ddl';
33
import pg from 'pg';
44
import { beforeAll, describe, expect, it } from 'vitest';
55
import { loadAppConfig } from '../src/app-config';
@@ -69,7 +69,7 @@ describe.skipIf(SKIP)('paradedb vector integration', () => {
6969
await client.query(
7070
`INSERT INTO public.vector_idx_probe VALUES (1, '[1,0,0]'), (2, '[0.1,0.9,0.1]'), (3, '[0,0,1]')`,
7171
);
72-
const ddl = renderBm25IndexDdl({
72+
const ddl = renderParadeDbIndexDdl({
7373
name: 'vector_idx_probe_idx',
7474
table: 'vector_idx_probe',
7575
schema: 'public',

paradedb/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ParadeDB full-text and vector search extension pack for Prisma Next.
44

55
## Overview
66

7-
This extension pack registers `'paradedb'` and `'bm25'` index types with the SQL family's index-type registry, so contracts can author BM25 full-text search indexes via the standard `constraints.index(...)` surface and the Postgres adapter emits `CREATE INDEX ... USING paradedb WITH (...)` (or `USING bm25`) DDL. `paradedb` is the primary access method name on pg_search 0.25.0+ (unreleased); `bm25` is a permanent backwards-compatible alias and the only name on released servers (<= 0.24.3).
7+
This extension pack registers `'paradedb'` and `'bm25'` index types with the SQL family's index-type registry, so contracts can author BM25 full-text search indexes via the standard `constraints.index(...)` surface and the Postgres adapter emits `CREATE INDEX ... USING paradedb WITH (...)` (or `USING bm25`) DDL. `paradedb` is the primary access method name on pg_search 0.25.0+ (unreleased); `bm25` is a permanent backwards-compatible alias and the only name on released servers (<= 0.24.3). The DDL helper API is likewise also available under bm25 names (`renderBm25IndexDdl`, `Bm25IndexDdlOptions`, `Bm25VectorIndexColumn`).
88

99
The v1 surface covers the `key_field` storage parameter only. Per-field tokenizer and column configuration is deferred to expression-index support.
1010

@@ -15,7 +15,7 @@ It also provides native pgvector `vector(n)` column support (no pgvector ORM lib
1515
- **Index registration**: declares `'paradedb'` (primary) and `'bm25'` (alias) entries via `defineIndexTypes()` carrying an arktype validator for the options shape
1616
- **Vector columns**: `vectorColumn(dimensions)` maps to `vector(n)` DDL; the `paradedb/vector@1` codec serializes `number[]``'[1,2,3]'` in both directions
1717
- **Vector queries**: `paradeDbL2Distance` (`<->`), `paradeDbCosineDistance` (`<=>`), `paradeDbInnerProduct` (`<#>`), and `paradeDbAll` (`@@@ pdb.all()`)
18-
- **Vector index DDL**: `renderBm25IndexDdl(...)` renders `CREATE INDEX ... USING paradedb` (or `USING bm25` via the `am` option) statements with per-column vector opclasses for raw migrations
18+
- **Vector index DDL**: `renderParadeDbIndexDdl(...)` renders `CREATE INDEX ... USING paradedb` (or `USING bm25` via the `am` option) statements with per-column vector opclasses for raw migrations
1919
- **Extension descriptor**: declares the `paradedb/bm25` and `paradedb/vector` capabilities for contract-level feature detection
2020
- **Pack ref export**: ships a pure `/pack` entrypoint for TypeScript contract authoring
2121

@@ -97,9 +97,9 @@ The column emits `vector(3)` DDL and reads/writes `number[]` values.
9797
Vector columns listed in a `constraints.index([...], { type: 'paradedb', ... })` declaration get the AM's default opclass, `vector_l2_ops` (L2). The contract index surface cannot express per-column opclasses yet, so for the cosine or inner-product metric render the DDL for a raw migration:
9898

9999
```typescript
100-
import { renderBm25IndexDdl } from '@prisma-next/extension-paradedb/ddl';
100+
import { renderParadeDbIndexDdl } from '@prisma-next/extension-paradedb/ddl';
101101

102-
renderBm25IndexDdl({
102+
renderParadeDbIndexDdl({
103103
name: 'item_vector_idx',
104104
table: 'item',
105105
keyField: 'id',
@@ -147,7 +147,7 @@ The ORDER BY distance operator must match the index opclass metric; a mismatch d
147147
## Not yet implemented
148148

149149
- Per-column / per-expression tokenizer configuration (deferred to expression-index support)
150-
- Per-column vector opclasses in `constraints.index(...)` (use `renderBm25IndexDdl` meanwhile)
150+
- Per-column vector opclasses in `constraints.index(...)` (use `renderParadeDbIndexDdl` meanwhile)
151151
- `halfvec` / `sparsevec` column types
152152
- `CREATE EXTENSION pg_search` / `CREATE EXTENSION vector` via migration planner (removed with upstream's `databaseDependencies` hook; install the extensions before `db init`)
153153
- Aggregation and highlight functions

paradedb/src/core/bm25-index-ddl.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,8 @@ export function renderBm25IndexDdl(options: Bm25IndexDdlOptions): string {
101101
: `${quoteIdentifier(options.schema)}.${quoteIdentifier(options.table)}`;
102102
return `CREATE INDEX ${quoteIdentifier(options.name)} ON ${qualifiedTable} USING ${am} (${columnList}) WITH (key_field = '${escapeLiteral(options.keyField)}')`;
103103
}
104+
105+
// Primary paradedb-named API; the bm25 names above remain supported aliases.
106+
export type ParadeDbVectorIndexColumn = Bm25VectorIndexColumn;
107+
export type ParadeDbIndexDdlOptions = Bm25IndexDdlOptions;
108+
export const renderParadeDbIndexDdl = renderBm25IndexDdl;

paradedb/src/exports/ddl.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
export {
22
type Bm25IndexDdlOptions,
33
type Bm25VectorIndexColumn,
4+
type ParadeDbIndexDdlOptions,
5+
type ParadeDbVectorIndexColumn,
46
type VectorMetric,
57
renderBm25IndexDdl,
8+
renderParadeDbIndexDdl,
69
VECTOR_DISTANCE_OPERATORS,
710
VECTOR_OPCLASSES,
811
} from '../core/bm25-index-ddl';

paradedb/test/vector.test.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { OperationExpr, ParamRef } from '@prisma-next/sql-relational-core/ast';
22
import { describe, expect, it } from 'vitest';
3-
import { renderBm25IndexDdl, VECTOR_DISTANCE_OPERATORS, VECTOR_OPCLASSES } from '../src/exports/ddl';
3+
import {
4+
type ParadeDbIndexDdlOptions,
5+
type ParadeDbVectorIndexColumn,
6+
renderBm25IndexDdl,
7+
renderParadeDbIndexDdl,
8+
VECTOR_DISTANCE_OPERATORS,
9+
VECTOR_OPCLASSES,
10+
} from '../src/exports/ddl';
411
import { paradedbPackMeta } from '../src/core/descriptor-meta';
512
import {
613
expandVectorNativeType,
@@ -151,6 +158,20 @@ describe('renderBm25IndexDdl', () => {
151158
);
152159
});
153160

161+
it('is also exported under the primary paradedb name', () => {
162+
expect(renderParadeDbIndexDdl).toBe(renderBm25IndexDdl);
163+
const embedding: ParadeDbVectorIndexColumn = { column: 'embedding', metric: 'cosine' };
164+
const options: ParadeDbIndexDdlOptions = {
165+
name: 'idx',
166+
table: 'item',
167+
keyField: 'id',
168+
columns: ['id', embedding],
169+
};
170+
expect(renderParadeDbIndexDdl(options)).toBe(
171+
'CREATE INDEX "idx" ON "item" USING paradedb ("id", "embedding" vector_cosine_ops) WITH (key_field = \'id\')',
172+
);
173+
});
174+
154175
it('rejects unknown access methods', () => {
155176
expect(() =>
156177
renderBm25IndexDdl({

0 commit comments

Comments
 (0)