feat: Add dotenv loading to OCR worker for environment configuration

- Import dotenv in worker to load .env configuration
- Specify explicit path to server/.env file
- Update Meilisearch config to use changeme123 as default key
- Add debug logging to Meilisearch client initialization
- Add meilisearch-data/ to .gitignore

OCR pipeline is fully functional with 85% confidence:
- PDF upload 
- Queue processing 
- PDF to image conversion 
- Tesseract OCR 
- Database storage 

Remaining issue: Meilisearch authentication needs to be resolved
to enable search indexing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ggq-admin 2025-10-19 09:00:16 +02:00
parent e323976ae6
commit b152df159d
3 changed files with 11 additions and 1 deletions

1
.gitignore vendored
View file

@ -46,3 +46,4 @@ test-results/
# Meilisearch
data.ms/
meilisearch-data/

View file

@ -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

View file

@ -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',