ProtectedColocatedThe host relational connection a colocated provider borrows to store and query
vectors in the same database as the application's entity data. undefined until
SetColocatedHost (or TryWireColocatedHost) is called.
ProtectedApiOnly sub-classes can access the API key
True when this driver does not accept ingestion via CreateRecord(s) /
UpdateRecord(s) — implies vectors are managed out-of-band (e.g.
SimpleVectorServiceProvider reads embeddings directly from
MJ: Entity Record Documents.VectorJSON). Pipelines that would
otherwise call ingestion APIs should short-circuit when this is true
to avoid spurious "unsupported" error logs.
Subclasses that genuinely support ingestion leave the default false.
Whether this provider's QueryIndex/HybridQuery params.id is the EntityDocumentID
(a GUID) rather than an external/logical index name. External services (Pinecone, Qdrant)
and DB-colocated providers key by an index name and return false (the default). The
in-process SimpleVectorServiceProvider reads vectors out of
MJ: Entity Record Documents keyed by EntityDocumentID, so it overrides this to true.
Callers that hold both identifiers (e.g. the duplicate-record detector) consult this to
pass the correct id for the resolved provider instead of assuming index-name semantics.
Whether this provider requires an API key / credential to operate. Defaults to true
for external, cloud-hosted vector services (Pinecone, Qdrant, …). Override and return
false for in-process / local providers that authenticate via the host process or the
application's own database rather than a remote credential — e.g. the in-memory
SimpleVectorServiceProvider, which reads vectors out of MJ: Entity Record Documents.VectorJSON and never calls an external service.
Callers that gate on a missing key (e.g. the Entity Vector Sync pipeline and the duplicate-record detector) consult this so a keyless local provider isn't rejected with a spurious "No API Key found" error.
Whether this provider stores vectors inside the application's relational database and
can resolve query results to entity records without an external mapping hop. Override
and return true in colocated providers (e.g. PgVectorColocated, SQLServerVectorDatabase).
Whether this provider supports hybrid (vector + full-text) search.
Currently returns false. While pgvector combined with PostgreSQL's
tsvector/pg_trgm could support hybrid search, this is not
implemented in the initial release.
Build a pgvector-native metadata filter from the shared SharedIndexFilterOptions interface used across all MJ vector providers.
The shared filter options (EntityName, RecordIDs, etc.) are first converted to
generic MetadataFilterCondition objects via VectorMetadataFilter.BuildConditions,
then wrapped in an internal _pgvectorConditions envelope that the private
BuildFilterClause helper translates into parameterized SQL WHERE clauses.
The provider-agnostic filter options.
An opaque filter object to pass as QueryOptions.filter, or undefined
if the options produce no conditions.
Build per-record routing and operational directives for this provider.
Called by the generic sync pipeline once per source database row, before the
VectorRecord is constructed. The returned object is stored on
VectorRecord.providerTemporaryDirectives and passed to CreateRecords alongside
the stored metadata — but is never itself persisted in the vector index.
Providers override this to extract whatever routing values they need from
providerConfig (the parsed VectorIndex.ProviderConfig JSON) and from
sourceRecord (the raw database row). Example: the Pinecone driver reads
providerConfig.namespaceField, looks up the corresponding value in sourceRecord,
and returns { namespace: '<orgId>' } so CreateRecords can route each vector
to the correct Pinecone namespace without embedding org data in the stored metadata.
The default implementation returns an empty object — providers that do not need per-record routing need not override this method.
The raw database row being vectorized.
The parsed VectorIndex.ProviderConfig JSON blob.
An opaque key/value map consumed by this provider's CreateRecord(s).
Run a colocated query that fuses a vector component with an optional keyword component
in a single server-side statement, applying an optional metadata filter. Only meaningful
when SupportsColocatedQuery is true; the default implementation throws to surface
misuse on providers that don't support it.
Optional_contextUser: UserInfoCreate a new vector index backed by a PostgreSQL table.
This method:
id, embedding, and metadata columns.embedding column using the appropriate
operator class for the requested distance metric.metadata JSONB column.If the table or indexes already exist they are left untouched (IF NOT EXISTS).
Index creation parameters including id (table name),
dimension (vector size), and optional metric (defaults to 'cosine').
A BaseResponse with data containing the created index metadata
on success, or a failure response on error.
Insert or update a single vector record in the specified index. Delegates to CreateRecords with a single-element array.
The vector record to upsert (id, values, and optional metadata).
OptionalindexName: stringThe target index (table) name. Required.
A BaseResponse indicating success or failure.
Insert or update multiple vector records in the specified index.
Uses a transactional batch of INSERT ... ON CONFLICT DO UPDATE statements
so that existing records are overwritten atomically.
Array of vector records to upsert.
OptionalindexName: stringThe target index (table) name. Required.
A BaseResponse with data.upsertedCount on success,
or a failure response on error.
Delete all records from an index. Executes an unqualified DELETE FROM on the
underlying table, leaving the table structure and indexes intact.
The target index (table) name.
Optional_namespace: stringIgnored; pgvector does not use namespaces.
A BaseResponse indicating success or failure.
Delete a vector index by dropping its PostgreSQL table and removing it from the internal registry.
Request parameters; params.id must be the index (table) name.
A BaseResponse indicating success or failure.
Delete a single vector record from an index.
The record to delete; only record.id is used.
OptionalindexName: stringThe target index (table) name. Required.
A BaseResponse indicating success or failure.
Delete multiple vector records from an index in a single DELETE ... IN (...) query.
The records to delete; only their id fields are used.
OptionalindexName: stringThe target index (table) name. Required.
A BaseResponse indicating success or failure.
Edit an existing index. Currently not supported for pgvector -- returns a failure response. Reserved for future operations such as renaming tables or altering vector dimensions.
Edit parameters (unused).
A failure BaseResponse indicating the operation is unsupported.
Retrieve metadata for a single index by name.
Request parameters; params.id must be the index (table) name.
A BaseResponse whose data is an IndexDescription on success,
or a failure response if the index does not exist.
Retrieve a single vector record by ID.
Request parameters. params.id is the record ID and
params.data.indexName is the target index (table) name (required).
A BaseResponse whose data is a VectorRecord on success,
or a failure response if not found.
Retrieve multiple vector records by their IDs.
Request parameters. params.data.indexName is the target index
(table) name and params.data.ids is the array of record IDs to fetch.
Both are required.
A BaseResponse whose data is an array of VectorRecord
objects on success, or a failure response on error.
Perform a hybrid search combining vector similarity with keyword (BM25) matching. Only available on providers where SupportsHybridSearch is true. Default implementation falls back to a standard vector QueryIndex call.
OptionalcontextUser: UserInfoList all vector indexes (tables) managed by this provider.
Queries the internal registry table to return index names, dimensions,
and distance metrics. The host field on each description is synthesized
from the configured PostgreSQL host and port.
An IndexList containing descriptions of every registered index. Returns an empty list on error.
List vector record IDs with optional metadata filtering and cursor-based pagination.
Results are ordered by id and paginated using an integer offset encoded as a
string token. When the returned array contains fewer items than Limit, there are
no more pages.
Parameters including IndexName, optional Limit (default 100),
optional PaginationToken (stringified offset), and optional MetadataFilter
(key-value pairs matched against the JSONB metadata column).
A ListVectorIDsResult with the matching IDs and an optional
NextPaginationToken for the next page.
Query the vector index with metadata filtering using SharedIndexFilterOptions.
Default implementation converts the filter options to a native filter object and delegates to QueryIndex. Providers can override BuildMetadataFilter() for custom filter syntax.
Standard query options with an additional metadataFilter field
OptionalcontextUser: UserInfoThe query response from the vector database
Perform an approximate nearest-neighbor search against a vector index.
The query vector is compared against all embeddings in the target table
using the distance operator associated with the index's metric. Results
are ordered by ascending distance and limited to topK rows. Distance
values are converted to similarity scores before being returned.
Optional metadata filters are translated into parameterized WHERE
clauses against the JSONB metadata column.
Query options including:
vector (number[]) -- the query embedding (required).id (string) -- the index (table) name (required).topK (number) -- maximum results to return (default 10).includeMetadata (boolean) -- include metadata in results (default true).includeValues (boolean) -- include raw vectors in results (default false).filter (object) -- optional metadata filter.Optional_contextUser: UserInfoA BaseResponse whose data is a QueryResponse containing
scored matches, or a failure response on error.
Wire in the host relational connection so this provider reuses it for colocated storage and queries instead of opening its own pool. No-op semantics for providers that ignore it; colocated providers require it before any operation.
Convenience used by callers that hold an opaque provider reference (the active MJ data
provider). If host implements IColocatedVectorHost and this provider supports
colocated queries, wire it in.
true if the host was wired in, false otherwise.
Update a single vector record's embedding and/or metadata.
Only the fields present on the UpdateOptions object are updated; omitted fields are left unchanged.
Update options including id, optional values (new embedding),
optional metadata, and a required indexName property identifying the
target index (table).
A BaseResponse indicating success or failure.
Update records in batch. Currently delegates to UpdateRecord since the base class signature accepts a single UpdateOptions object.
The update options (single record).
A BaseResponse indicating success or failure.
ProtectedwrapBuild a standard FAILURE BaseResponse.
Always return this (never a success response) from a catch block — returning a
success response on error silently swallows real failures and makes callers, and the
vectorization pipeline, believe an operation worked when it did not.
Optionalmessage: stringOptional human-readable error detail; falls back to a generic message.
ProtectedwrapBuild a standard SUCCESS BaseResponse. Shared across all drivers so every provider reports results in a uniform shape.
The provider-specific payload to attach to the response.
MemberJunction vector database provider backed by PostgreSQL with the pgvector extension.
How it works: Each logical "index" is represented as a PostgreSQL table with three columns:
id(TEXT primary key),embedding(pgvectorVECTOR(N)column), andmetadata(JSONB). An internal registry table (_mj_vector_indexes) tracks all indexes created by this provider along with their dimension and distance metric.On first use, the provider auto-creates the
vectorextension, the configured schema, and the registry table. Each new index gets an HNSW index for fast approximate nearest-neighbor search and a GIN index on the metadata column for efficient JSONB filtering.Connection: Supply a JSON connection string as the
apiKeyconstructor parameter, or configure individual fields via environment variables (PG_VECTOR_HOST,PG_VECTOR_PORT, etc.). If theapiKeyis not valid JSON it is treated as a plain password with all other values sourced from environment variables.Distance metrics: Supports
cosine(default,<=>),euclidean(<->), anddotproduct(<#>).Registered with the MJ class factory as
'PgVectorDatabase'.