| # MeiliSearch Connection Guide | |
| ## Connection Details | |
| - **Host**: localhost | |
| - **Port**: 17005 (HTTP) | |
| - **Protocol**: HTTP/REST API | |
| - **Health Check**: `curl http://localhost:17005/health` | |
| - **Dashboard**: http://localhost:17005 (if web interface enabled) | |
| ## Authentication | |
| - **Master Key**: `VEtAgT0a284o9WMsVHI0567fO6pc5BvqvKeqyhrVzTM` (auto-generated) | |
| - **Environment**: Development (no authentication required for localhost) | |
| - **Security**: Add master key for production use | |
| ## REST API Examples | |
| ```bash | |
| # Health check (no auth required) | |
| curl http://localhost:17005/health | |
| # Get version info | |
| curl http://localhost:17005/version | |
| # List indexes (requires master key) | |
| curl -H "Authorization: Bearer VEtAgT0a284o9WMsVHI0567fO6pc5BvqvKeqyhrVzTM" \ | |
| http://localhost:17005/indexes | |
| # Create index for Nova memories | |
| curl -X POST "http://localhost:17005/indexes" \ | |
| -H "Content-Type: application/json" \ | |
| -H "Authorization: Bearer VEtAgT0a284o9WMsVHI0567fO6pc5BvqvKeqyhrVzTM" \ | |
| -d '{ | |
| "uid": "nova_memories", | |
| "primaryKey": "memory_id" | |
| }' | |
| # Add documents to index | |
| curl -X POST "http://localhost:17005/indexes/nova_memories/documents" \ | |
| -H "Content-Type: application/json" \ | |
| -H "Authorization: Bearer VEtAgT0a284o9WMsVHI0567fO6pc5BvqvKeqyhrVzTM" \ | |
| -d '[ | |
| { | |
| "memory_id": "mem_001", | |
| "content": "User authentication successful", | |
| "timestamp": "2025-08-29T01:00:00Z", | |
| "type": "authentication", | |
| "importance": 8 | |
| }, | |
| { | |
| "memory_id": "mem_002", | |
| "content": "Database connection established", | |
| "timestamp": "2025-08-29T01:05:00Z", | |
| "type": "system", | |
| "importance": 9 | |
| } | |
| ]' | |
| # Search memories | |
| curl -X POST "http://localhost:17005/indexes/nova_memories/search" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "q": "authentication database", | |
| "limit": 10, | |
| "offset": 0 | |
| }' | |
| ``` | |
| ## Python Client Example | |
| ```python | |
| from meilisearch import Client | |
| from meilisearch.index import Index | |
| # Connect to MeiliSearch | |
| client = Client( | |
| 'http://localhost:17005', | |
| 'VEtAgT0a284o9WMsVHI0567fO6pc5BvqvKeqyhrVzTM' # Master key | |
| ) | |
| # Get server health | |
| health = client.health() | |
| print(f"MeiliSearch health: {health['status']}") | |
| # Create index for Nova session data | |
| index = client.index('nova_sessions') | |
| # Configure searchable attributes | |
| index.update_settings({ | |
| 'searchableAttributes': ['session_id', 'user_id', 'actions', 'outcome'], | |
| 'filterableAttributes': ['timestamp', 'status', 'duration'], | |
| 'sortableAttributes': ['timestamp', 'importance'] | |
| }) | |
| # Add session documents | |
| session_data = [ | |
| { | |
| "session_id": "sess_202508290100", | |
| "user_id": "user_123", | |
| "timestamp": "2025-08-29T01:00:00Z", | |
| "actions": ["login", "query", "logout"], | |
| "duration": 120, | |
| "status": "completed", | |
| "outcome": "success", | |
| "importance": 7 | |
| }, | |
| { | |
| "session_id": "sess_202508290105", | |
| "user_id": "user_456", | |
| "timestamp": "2025-08-29T01:05:00Z", | |
| "actions": ["search", "update", "save"], | |
| "duration": 85, | |
| "status": "completed", | |
| "outcome": "partial_success", | |
| "importance": 6 | |
| } | |
| ] | |
| index.add_documents(session_data) | |
| # Search sessions | |
| results = index.search('search update', { | |
| 'filter': 'status = "completed"', | |
| 'sort': ['timestamp:desc'], | |
| 'limit': 5 | |
| }) | |
| print(f"Found {len(results['hits'])} sessions:") | |
| for hit in results['hits']: | |
| print(f"- {hit['session_id']}: {hit['outcome']}") | |
| ``` | |
| ## JavaScript/Node.js Example | |
| ```javascript | |
| const { MeiliSearch } = require('meilisearch'); | |
| const client = new MeiliSearch({ | |
| host: 'http://localhost:17005', | |
| apiKey: 'VEtAgT0a284o9WMsVHI0567fO6pc5BvqvKeqyhrVzTM' | |
| }); | |
| // Create index for user queries | |
| async function setupNovaSearch() { | |
| const index = client.index('user_queries'); | |
| await index.updateSettings({ | |
| searchableAttributes: ['query_text', 'intent', 'response_summary'], | |
| filterableAttributes: ['timestamp', 'success_rate', 'complexity'], | |
| sortableAttributes: ['timestamp', 'usage_count'] | |
| }); | |
| const queries = [ | |
| { | |
| query_id: 'q_001', | |
| query_text: 'How to configure database connections', | |
| intent: 'technical_configuration', | |
| response_summary: 'Database configuration requires proper connection strings and authentication', | |
| timestamp: '2025-08-29T01:10:00Z', | |
| success_rate: 0.95, | |
| complexity: 'medium', | |
| usage_count: 15 | |
| } | |
| ]; | |
| await index.addDocuments(queries); | |
| // Search for similar queries | |
| const results = await index.search('database configuration', { | |
| filter: 'complexity = "medium"', | |
| limit: 10 | |
| }); | |
| console.log(`Found ${results.hits.length} relevant queries`); | |
| } | |
| ``` | |
| ## Configuration Notes | |
| - **Data Directory**: `/data/data/meilisearch/data/` | |
| - **Log Directory**: `/data/data/meilisearch/logs/` | |
| - **Max Memory**: Auto-managed (configurable) | |
| - **Backup Location**: `/data/adaptai/backups/meilisearch/` | |
| - **Index Settings**: Optimized for text search and filtering | |
| ## Index Management | |
| ```bash | |
| # Get index stats | |
| curl -H "Authorization: Bearer VEtAgT0a284o9WMsVHI0567fO6pc5BvqvKeqyhrVzTM" \ | |
| http://localhost:17005/indexes/nova_memories/stats | |
| # Update index settings | |
| curl -X PATCH "http://localhost:17005/indexes/nova_memories/settings" \ | |
| -H "Content-Type: application/json" \ | |
| -H "Authorization: Bearer VEtAgT0a284o9WMsVHI0567fO6pc5BvqvKeqyhrVzTM" \ | |
| -d '{ | |
| "rankingRules": [ | |
| "words", "typo", "proximity", "attribute", "sort", "exactness" | |
| ], | |
| "stopWords": ["the", "a", "an", "and", "or", "in"] | |
| }' | |
| # Delete index | |
| curl -X DELETE "http://localhost:17005/indexes/nova_memories" \ | |
| -H "Authorization: Bearer VEtAgT0a284o9WMsVHI0567fO6pc5BvqvKeqyhrVzTM" | |
| ``` | |
| ## Health Monitoring | |
| ```bash | |
| # Basic health check | |
| curl -s http://localhost:17005/health | jq . | |
| # System metrics | |
| curl -H "Authorization: Bearer VEtAgT0a284o9WMsVHI0567fO6pc5BvqvKeqyhrVzTM" \ | |
| http://localhost:17005/stats | |
| # Check all indexes | |
| curl -H "Authorization: Bearer VEtAgT0a284o9WMsVHI0567fO6pc5BvqvKeqyhrVzTM" \ | |
| http://localhost:17005/indexes | jq . | |
| # Monitor task queue | |
| curl -H "Authorization: Bearer VEtAgT0a284o9WMsVHI0567fO6pc5BvqvKeqyhrVzTM" \ | |
| http://localhost:17005/tasks | jq . | |
| ``` | |
| ## Security | |
| - ❗ Localhost binding only | |
| - ❗ Master key: `VEtAgT0a284o9WMsVHI0567fO6pc5BvqvKeqyhrVzTM` | |
| - ❗ Development mode - consider rotating master key for production | |
| - ❗ Monitor disk usage on /data partition | |
| - ❗ Regular backups recommended | |
| - ❗ Consider rate limiting for production use | |
| ## Backup Procedures | |
| ```bash | |
| # Manual backup (stop service first) | |
| sudo systemctl stop meilisearch | |
| sudo rsync -av /data/data/meilisearch/data/ /data/adaptai/backups/meilisearch/full_backup/ | |
| sudo systemctl start meilisearch | |
| # Export index data (per index) | |
| curl -H "Authorization: Bearer VEtAgT0a284o9WMsVHI0567fO6pc5BvqvKeqyhrVzTM" \ | |
| http://localhost:17005/indexes/nova_memories/documents \ | |
| > /data/adaptai/backups/meilisearch/nova_memories_export.json | |
| # Import index data | |
| curl -X POST "http://localhost:17005/indexes/nova_memories/documents" \ | |
| -H "Content-Type: application/json" \ | |
| -H "Authorization: Bearer VEtAgT0a284o9WMsVHI0567fO6pc5BvqvKeqyhrVzTM" \ | |
| --data-binary @/data/adaptai/backups/meilisearch/nova_memories_export.json | |
| ``` | |
| ``` |