npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@absolutejs/rag-postgres

v0.1.0

Published

PostgreSQL (pgvector) vector-store adapter for @absolutejs/rag

Readme

@absolutejs/rag-postgres

PostgreSQL storage for AbsoluteJS RAG with pgvector similarity, native full-text retrieval, metadata filtering and reusable plugin integration.

bun add @absolutejs/rag @absolutejs/rag-postgres
import { Elysia } from 'elysia';
import { createPostgresRAG } from '@absolutejs/rag-postgres';
import { ragPlugin } from '@absolutejs/rag';

const rag = createPostgresRAG({
  storeOptions: {
    connectionString: process.env.DATABASE_URL,
    dimensions: 1536,
    indexType: 'hnsw',
    lexicalMode: 'native',
  },
});
const app = new Elysia().use(ragPlugin({ path: '/rag', collection: rag.collection }));

The driver is Bun.SQL; no separate PostgreSQL client package is required. Use your model provider to generate embeddings with the configured dimensions.

Lexical retrieval

Native mode is the default. First use creates a GIN expression index over title, text, source and JSON metadata string values. Existing tables are indexed too; index creation can take time and block writes on a populated table, so initialize it during a planned migration window. Updates and deletions maintain the index through PostgreSQL.

Queries use PostgreSQL's simple configuration, match any query lexeme, rank with weighted ts_rank_cd, and break ties by chunk ID. They are parameterized; query punctuation is treated as text. Title, body, source and metadata receive successively lower weights. Only the requested top K rows cross into the app. Tenant and other supported metadata predicates run before ranking/limiting. Unsupported filters are rejected rather than partially applied. Native top K must be an integer between 0 and 10,000.

lexicalMode: 'portable' retains the existing RAG lexical scorer and its richer field-specific ranking. It loads filtered candidates into application memory. The engines have different tokenization and scores; native mode is not a claim of identical relevance ordering. Compare your corpus before relying on score thresholds. Vector retrieval remains unchanged.

Measured retrieval

The reproducible benchmark uses a deterministic local PostgreSQL 15 corpus at 1K, 10K and 100K rows, one selective query with tenant filtering, one warmup and ten trials. It verifies expected matches and retains EXPLAIN ANALYZE plans in the results. At 100K rows, native median/p95 were 2.08/2.79 ms versus 683.03/752.49 ms for portable scoring. Native transferred 10 rows; portable transferred 50,000. These are local warm-query measurements, excluding ingestion/index construction, provider calls and network deployment effects. The 1K fixture has no matching row in the selected tenant. This is not an Exa comparison or a web-scale benchmark.

RAG_LEXICAL_TEST_URL=postgres://... bun postgres/benchmarks/lexical.ts
RAG_LEXICAL_TEST_URL=postgres://... bun test postgres/tests

Run these from the repository root against an isolated test database. Fixture schemas are removed after execution. CI runs real PostgreSQL integration tests.

License

Apache-2.0.