n8n-nodes-hologres-vectorstore
v0.1.4
Published
n8n community node for Hologres Vector Store with HGraph index support
Maintainers
Readme
n8n-nodes-hologres-vectorstore
A n8n community node for using Hologres as a vector database with HGraph vector index support.
Features
- Vector Storage: Store documents and embedding vectors in Hologres
- HGraph Index Support: Leverage Hologres' HGraph vector index for high-performance similarity search
- Multiple Operation Modes:
- Get Many: Retrieve top-ranked documents for a given query
- Insert Documents: Insert documents into the vector store
- Update Documents: Update existing documents by ID
- Retrieve Documents: Retrieve documents for use with other AI nodes
- Retrieve Documents (As Tool): Use as a retrieval tool for AI Agents
- Flexible Configuration: Customize table names, column names, distance methods, and more
- Metadata Filtering: Filter documents based on metadata
Prerequisites
- n8n >= 1.0.0
- Hologres instance (version supporting HGraph vector index)
- Node.js >= 18
Installation
Community Node Installation (Recommended)
- In n8n, go to Settings > Community Nodes
- Click Install
- Enter the package name
n8n-nodes-hologres-vectorstore - Agree to the security prompt and wait for installation to complete
Manual Installation
npm install n8n-nodes-hologres-vectorstoreConfiguration
1. Create Hologres Credentials
Configure Hologres connection information in n8n:
| Parameter | Description | Default | |-----------|-------------|---------| | Host | Hologres instance address | localhost | | Port | Port number | 80 | | Database | Database name | postgres | | User | Username | - | | Password | Password | - | | Maximum Number of Connections | Maximum number of connections | 100 | | SSL | SSL connection options | disable | | Allow Unauthorized Certificates | Allow unauthorized certificates | false |
2. Node Configuration
General Parameters
| Parameter | Description | Default | |-----------|-------------|---------| | Table Name | Table name for storing vectors | n8n_hologres_vectors | | Dimensions | Vector dimensions (must match your embedding model output) | 1536 | | Distance Method | Distance calculation method | Cosine | | Embedding Batch Size | Number of documents to embed in a single batch | 10 |
Distance Methods
- Cosine: Cosine similarity (recommended for semantic search)
- Inner Product: Inner product
- Euclidean: Euclidean distance
Column Names Configuration
| Parameter | Description | Default | |-----------|-------------|---------| | ID Column Name | ID column name | id | | Vector Column Name | Vector column name | embedding | | Content Column Name | Content column name | text | | Metadata Column Name | Metadata column name | metadata |
HGraph Index Configuration
| Parameter | Description | Default | |-----------|-------------|---------| | Base Quantization Type | Base quantization type | rabitq | | Use Reorder | Whether to use reordering | true | | Precise Quantization Type | High-precision quantization type | fp32 | | Precise IO Type | High-precision index storage medium | block_memory_io | | Max Degree | Maximum connections per vertex | 64 | | EF Construction | Search depth during index construction | 400 |
Usage Examples
Insert Documents
- Select Insert Documents mode
- Connect an Embedding node (e.g., OpenAI Embeddings)
- Connect a Document node (providing documents to store)
- Configure table name and vector dimensions
- Optional: Adjust Embedding Batch Size if your embedding model has batch size limits
- Run the workflow
Note: Documents are processed in batches according to the Embedding Batch Size setting. This helps prevent timeout issues with large document sets or embedding models with strict batch limits.
Update Documents
- Select Update Documents mode
- Connect an Embedding node (for re-embedding the updated content)
- Connect a Document node (providing the updated document)
- Enter the ID of the document to update
- Configure table name and column names (if different from defaults)
- Run the workflow
Note: The update operation will re-embed the document content and update both the vector and metadata in the database.
Retrieve Documents
- Select Get Many or Retrieve Documents mode
- Connect an Embedding node
- Enter a search prompt
- Set the number of results to return (Limit)
- Optional: Configure metadata filters
Use as AI Agent Tool
- Select Retrieve Documents (As Tool) mode
- Configure the tool name and description
- Connect to an AI Agent node
Execute Mode (Direct Query)
When used in execute mode (with a Main input connection), the node expects the input item to contain either:
chatInputfield - The query stringqueryfield - Alternative query field
This allows direct querying of the vector store without an AI Agent.
Development
# Install dependencies
npm install
# Development mode (hot reload)
npm run dev
# Code formatting
npm run format
# Build
npm run build
# Linting
npm run lint
# Publish
npm publish --dry-run
npm publishTesting
This project includes both unit tests and integration tests.
Unit Tests
Unit tests use mocked database connections and can run without a real Hologres instance.
# Run unit tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage report
npm run test:coverageIntegration Tests
Integration tests require a real Hologres database connection to test actual database operations.
Setup
Copy the example environment file:
cp .env.test.example .env.testEdit
.env.testwith your Hologres connection details:HOLOGRES_HOST=your-instance.hologres.aliyuncs.com HOLOGRES_PORT=80 HOLOGRES_DATABASE=your_database HOLOGRES_USER=your_user HOLOGRES_PASSWORD=your_password
Run Integration Tests
# Run integration tests only
npm run test:integration
# Run all tests (unit + integration)
npm run test:allNote: Integration tests will be automatically skipped if the database connection is not configured. This allows CI/CD pipelines to run unit tests without requiring a database.
Test Structure
__tests__/
├── setup.ts # Global mock setup for unit tests
├── mocks/
│ ├── pg.mock.ts # PostgreSQL client mocks
│ ├── embeddings.mock.ts # Fake embeddings for testing
│ ├── hologres-store.mock.ts # HologresVectorStore mocks
│ └── n8n-context.mock.ts # n8n execution context mocks
├── unit/
│ ├── HologresVectorStore.test.ts # Core vector store tests
│ └── helpers.test.ts # Helper function tests
└── integration/
├── setup.ts # Integration test configuration
├── HologresVectorStore.integration.test.ts # Core DB operations
├── VectorStoreHologres.node.integration.test.ts # Node tests
├── configurations.integration.test.ts # Configuration tests
├── edge-cases.integration.test.ts # Edge case handling
├── error-handling.integration.test.ts # Error handling tests
├── node-parameters.integration.test.ts # Node parameter tests
└── performance.integration.test.ts # Performance testsCoverage
Current test coverage:
| Metric | Coverage | |--------|----------| | Statements | 100% | | Branches | 96% | | Functions | 100% | | Lines | 100% |
Tech Stack
- n8n-workflow - n8n workflow SDK
- @langchain/core - LangChain core library
- pg - PostgreSQL client
License
Apache-2.0
