Skip to content
NEWMeet Alaaddin, your AI genie with a voice. trig8n launches 1 January 2027. See what is new

Library / RAG & Knowledge Bases

RAG & Knowledge Bases

Build a Google Drive document similarity database with Ollama and Postgres

When a chat message arrives, it answers questions from your own knowledge base with Ollama using Chat, Ollama, PGVector, Google Drive.

What it does

## AI-Powered Duplicate Checker & Internal Linking Assistant ### Process source documents to analyze semantic similarity and interactively query vector datasets for internal linking opportunities. This complete workflow operates in two primary modes: batch pipeline processing and real-time interactive query handling. It scans a Google Drive directory for website page documents, parses the text content, and stores the records in Postgres. Using Ollama and PGVector, it segments text into semantic chunks and generates vector embeddings. The system builds an HNSW index to calculate page-level centroids and global similarity metrics to flag duplicate content. Concurrently, an interactive chat interface captures user search queries, vectorizes the input in real time, executes localized similarity calculations against the database, and compiles downloadable internal linking opportunity reports. ### Setup steps - Configure Google Drive credentials and set the source folder or directory used by the scan and download nodes. - Configure Postgres credentials and ensure the database has pgvector enabled plus the required scraped-pages, vector, similarity, and report tables. - Configure the Ollama embeddings node with a locally available embedding model and ensure the Ollama service is reachable from n8n. - Review the SQL in the cleanup, embedding, similarity, centroid, aggregation, and reporting nodes so table names, thresholds, and index definitions match your database schema. - Set or verify the document filter criteria, text extraction settings, chunking parameters, and export file formats before running the manual trigger. - Configure the n8n Chat Trigger and response nodes to establish interactive communication, routing pathways, and operational rule validation loops within the user interface. - Align the live text splitting settings and local embedding models with the ingestion phase parameters to ensure query vector compliance. - Verify live-query SQL scripts to ensure real-time distance computations target the correct temporary vector tables and document schemas. ### Requirements - Google Drive credentials - PostgreSQL database with pgvector and HNSW index support - Ollama service running local embedding models - Active n8n Chat Interface configuration

The steps

  1. Loop Source File
  2. GDrive Download Document
  3. Extract Raw Text Content
  4. Save Scraped Page Text
  5. Batches for Embedding
  6. Get Unprocessed Scraped Text
  7. Save Document Embeddings
  8. Generate Local Embeddings
  9. Context Injector
  10. Chunk Text Recursively
  11. Dedup Processed Items
  12. Clear Vector Table
  13. Clear Scraped Pages Table
  14. Scan Source Directory

56 steps in total.

Similar automations