File size: 7,284 Bytes
67d20c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# 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
```

```