You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @naorpeled, I'd like to work on the remaining Bit and Sparsevec types. I'll reference the existing Vector/Halfvec PR (#11437) for the implementation pattern. Let me know if there's anything I should keep in mind.
Hi @naorpeled 👋 Following up on the index question above (HNSW / IVFFlat), since vector and halfvec landed in 0.3.27 and bit/sparsevec are in progress. I'd like to implement it and want to check the API shape with you first.
Why it needs more than a new type: pgvector defines no default operator class for hnsw (and for ivfflat only vector_l2_ops is the default), so USING hnsw ("embedding") fails, and cosine/inner-product indexes always need an explicit opclass. The operator class (vector_cosine_ops, vector_l2_ops, halfvec_ip_ops, …) and the build parameters (m, ef_construction, lists) both have to be expressible.
Proposed API (extends the existing type option):
@Index({type: "hnsw",// new: "hnsw" | "ivfflat" added to TableIndexTypes (postgres only)operatorClass: "vector_cosine_ops",// new: appended after the column(s)with: {m: 16,ef_construction: 64}// new: rendered as WITH (m = 16, ef_construction = 64)})
@Column({type: "vector",length: 1536})embedding: number[]
Generated SQL:
CREATE INDEX "IDX_…"ON"post" USING hnsw ("embedding" vector_cosine_ops) WITH (m =16, ef_construction =64)
IndexOptions / IndexMetadata / TableIndex: add operatorClass?: string and with?: Record<string, number | string | boolean>
PostgresQueryRunner.createIndexSql() (+ view variant): emit the opclass after the columns and a WITH (…) clause
Schema loading: read the opclass (pg_index.indclass → pg_opclass.opcname) and pg_class.reloptions, and include both in index comparison, so migration:generate doesn't drop and recreate the index on every run
Tests: extend test/functional/indices/index-types with hnsw + ivfflat entities (the pgvector image is already in docker-compose), plus a migration-diff test showing no changes on the second run. Docs in the indices page.
Open questions:
Naming: operatorClass + with, or something closer to existing options (e.g. opclass, storageParameters)?
Would you prefer one PR, or splitting create-SQL (1–3) from introspection/diff (4)?
Happy to adjust. If this looks right, I'll open a draft PR.
Activity
Danbaba1 commentedon May 26, 2025
I will take Halfvec
naorpeled commentedon May 26, 2025
Amazing! Let me know if you need any assistance
Danbaba1 commentedon May 27, 2025
Okay I will. Thank you
GuillaumeMunsch commentedon Aug 27, 2025
Hey,
Do you guys have any visibility on this? 🙏
vihardesu commentedon Sep 11, 2025
is this ready??
naorpeled commentedon Sep 13, 2025
Hey @Danbaba1,
as part of my
vectorPR, I'm already addinghalfvec.Let me know if you'd like to take any other data type 🙏
naorpeled commentedon Sep 13, 2025
Yes, this PR.
I'm currently finalizing it, hoping to get it merged in the next few days.
naorpeled commentedon Sep 13, 2025
Almost done 🙏
i-tengfei commentedon Nov 1, 2025
Index support? like:
naorpeled commentedon Nov 22, 2025
I'll raise this topic in the next maintainers meeting and keep you posted 🙏
naorpeled commentedon Nov 22, 2025
Both
VectorandHalfvecwere added in v0.3.27 😎Cprakhar commentedon Jan 13, 2026
@naorpeled I have created a draft for
BitandSparsevec. I would appreciate your review.kyungseopk1m commentedon Mar 29, 2026
Hi @naorpeled, I'd like to work on the remaining Bit and Sparsevec types. I'll reference the existing Vector/Halfvec PR (#11437) for the implementation pattern. Let me know if there's anything I should keep in mind.
LeonxLJX commentedon Sep 1, 2026
I'd like to take this one (
PGVector support). I'll look into the root cause and follow up with a PR. (claiming via @LeonxLJX)LeonxLJX commentedon Sep 1, 2026
I'd like to take this one (
PGVector support). I'll look into the root cause and follow up with a PR. (claiming via @LeonxLJX)LeonxLJX commentedon Sep 1, 2026
I'd like to take this one (
PGVector support). I'll dig into the root cause and follow up with a PR shortly. (claiming via @LeonxLJX)aneesahmed330 commentedon Nov 26, 2026
Hi @naorpeled 👋 Following up on the index question above (HNSW / IVFFlat), since vector and halfvec landed in 0.3.27 and bit/sparsevec are in progress. I'd like to implement it and want to check the API shape with you first.
Why it needs more than a new
type: pgvector defines no default operator class forhnsw(and forivfflatonlyvector_l2_opsis the default), soUSING hnsw ("embedding")fails, and cosine/inner-product indexes always need an explicit opclass. The operator class (vector_cosine_ops,vector_l2_ops,halfvec_ip_ops, …) and the build parameters (m,ef_construction,lists) both have to be expressible.Proposed API (extends the existing
typeoption):Generated SQL:
Plan:
TableIndexTypes+PostgresDriver.supportedIndexTypes: addhnsw,ivfflatIndexOptions/IndexMetadata/TableIndex: addoperatorClass?: stringandwith?: Record<string, number | string | boolean>PostgresQueryRunner.createIndexSql()(+ view variant): emit the opclass after the columns and aWITH (…)clausepg_index.indclass→pg_opclass.opcname) andpg_class.reloptions, and include both in index comparison, somigration:generatedoesn't drop and recreate the index on every runtest/functional/indices/index-typeswith hnsw + ivfflat entities (the pgvector image is already in docker-compose), plus a migration-diff test showing no changes on the second run. Docs in the indices page.Open questions:
operatorClass+with, or something closer to existing options (e.g.opclass,storageParameters)?Happy to adjust. If this looks right, I'll open a draft PR.