Member Junction
    Preparing search index...

    Colocated MemberJunction vector provider backed by SQL Server 2025 native vectors (VECTOR(N) + the VECTOR_SEARCH DiskANN table-valued function), stored in the application's own database. Borrows the active data provider's connection via IColocatedVectorHost.

    Two storage modes (per index, via MJVectorIndex.ProviderConfigCreateIndexParams.additionalParams):

    • sibling (default): MJ creates and owns a sibling table (id/embedding/metadata/content). Generic, entity-agnostic, multi-model. Filters resolve against the JSON metadata column.
    • entityColumn: vectors live on an existing entity table's VECTOR column. Filters resolve against live entity columns, and results project real entity fields. This is the migration target for systems that already store embeddings on their own tables (e.g. a Content.Embedding column) — point MJ at the column instead of re-vectorizing.

    Query path prefers the DiskANN-aware VECTOR_SEARCH TVF (never ORDER BY VECTOR_DISTANCE, which doesn't engage the index). But that surface isn't in every 2025 build — verified live, boxed SQL Server 2025 RTM lacks it — so the provider lazily detects (per host) whether VECTOR_SEARCH works and falls back to an exact VECTOR_DISTANCE scan when it doesn't. Where the TVF exists, filtered queries dispatch on cardinality: small filtered sets use the exact path (DiskANN doesn't converge when the filter cluster is disjoint from the query neighborhood), large sets use DiskANN. See sqlserverColocatedSQL for the production-verified SQL shapes and the reasoning behind each.

    Validated end-to-end against a live SQL Server 2025 RTM container in sibling and entityColumn modes (exact fallback path). The approximate path on Azure SQL Database remains untested.

    Registered with the MJ class factory as 'SQLServerVectorDatabase'.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    ColocatedHost: IColocatedVectorHost

    The 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.

    Accessors

    • get ApiKey(): string

      Only sub-classes can access the API key

      Returns string

    • get IsReadOnly(): boolean

      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.

      Returns boolean

    • get QueryKeyIsEntityDocumentID(): boolean

      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.

      Returns boolean

    • get RequiresAPIKey(): boolean

      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.

      Returns boolean

    • get SupportsColocatedQuery(): boolean

      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).

      Returns boolean

    Methods

    • 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.

      Parameters

      • _sourceRecord: Record<string, unknown>

        The raw database row being vectorized.

      • _providerConfig: Record<string, unknown>

        The parsed VectorIndex.ProviderConfig JSON blob.

      Returns Record<string, unknown>

      An opaque key/value map consumed by this provider's CreateRecord(s).

    • Query an index for nearest neighbours.

      Parameters

      • params: QueryOptions

        Query parameters (vector or record id, topK, filter, etc.)

      • OptionalcontextUser: UserInfo

        Optional caller identity. Remote drivers (Pinecone, Qdrant, pgvector) authenticate via their own credentials and ignore this parameter. In-process drivers that need to honor server-side row-level security (e.g. SimpleVectorDatabase, which calls RunView to load entity vectors) require it. Pattern matches MJ's RunView(params, contextUser) and GetEntityObject(name, contextUser) conventions.

      Returns Promise<BaseResponse>

    • 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.

      Parameters

      Returns void

    • 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.

      Parameters

      • host: unknown

      Returns boolean

      true if the host was wired in, false otherwise.

    • Build 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.

      Parameters

      • Optionalmessage: string

        Optional human-readable error detail; falls back to a generic message.

      Returns BaseResponse

    • Build a standard SUCCESS BaseResponse. Shared across all drivers so every provider reports results in a uniform shape.

      Parameters

      • data: unknown

        The provider-specific payload to attach to the response.

      Returns BaseResponse