diff --git a/.gitignore b/.gitignore index da7d206..3890fb2 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ test-results/ # Meilisearch data.ms/ +meilisearch-data/ diff --git a/server/config/meilisearch.js b/server/config/meilisearch.js index 2d10884..0af6798 100644 --- a/server/config/meilisearch.js +++ b/server/config/meilisearch.js @@ -10,7 +10,7 @@ import { dirname, join } from 'path'; const __dirname = dirname(fileURLToPath(import.meta.url)); const MEILISEARCH_HOST = process.env.MEILISEARCH_HOST || 'http://127.0.0.1:7700'; -const MEILISEARCH_MASTER_KEY = process.env.MEILISEARCH_MASTER_KEY || 'masterKey'; +const MEILISEARCH_MASTER_KEY = process.env.MEILISEARCH_MASTER_KEY || 'changeme123'; const INDEX_NAME = process.env.MEILISEARCH_INDEX_NAME || 'navidocs-pages'; let client = null; @@ -18,6 +18,7 @@ let index = null; export function getMeilisearchClient() { if (!client) { + console.log(`[Meilisearch] Initializing client with host=${MEILISEARCH_HOST}, apiKey=${MEILISEARCH_MASTER_KEY}`); client = new MeiliSearch({ host: MEILISEARCH_HOST, apiKey: MEILISEARCH_MASTER_KEY diff --git a/server/workers/ocr-worker.js b/server/workers/ocr-worker.js index a54ad5f..dd57aad 100644 --- a/server/workers/ocr-worker.js +++ b/server/workers/ocr-worker.js @@ -11,13 +11,21 @@ * - Handle failures and update job status */ +import dotenv from 'dotenv'; import { Worker } from 'bullmq'; import Redis from 'ioredis'; import { v4 as uuidv4 } from 'uuid'; +import { dirname, join } from 'path'; +import { fileURLToPath } from 'url'; import { getDb } from '../config/db.js'; import { extractTextFromPDF, cleanOCRText } from '../services/ocr.js'; import { indexDocumentPage } from '../services/search.js'; +const __dirname = dirname(fileURLToPath(import.meta.url)); + +// Load environment variables from server directory +dotenv.config({ path: join(__dirname, '../.env') }); + // Redis connection for BullMQ const connection = new Redis({ host: process.env.REDIS_HOST || '127.0.0.1',