new redis migration

Signed-off-by: ale <ale@manalejandro.com>
Este commit está contenido en:
ale
2025-12-15 16:35:35 +01:00
padre ad7a1cf0a7
commit 3ce64eeb8e
Se han modificado 20 ficheros con 1021 adiciones y 712 borrados

Ver fichero

@@ -9,7 +9,7 @@ This guide will help you quickly set up and test the Hasher application.
Ensure you have:
- ✅ Node.js 18.x or higher (`node --version`)
- ✅ npm (`npm --version`)
-Elasticsearch running on `localhost:9200`
-Redis running on `localhost:6379`
### 2. Installation
@@ -26,7 +26,7 @@ npm run dev
The application will be available at: **http://localhost:3000**
### 3. Verify Elasticsearch Connection
### 3. Verify Redis Connection
```bash
# Check health endpoint
@@ -37,7 +37,15 @@ Expected response:
```json
{
"status": "ok",
"elasticsearch": { ... }
"redis": {
"version": "7.x",
"memory": "1.5M",
"dbSize": 0
},
"stats": {
"count": 0,
"size": 0
}
}
```
@@ -86,20 +94,18 @@ npm run index-file sample-wordlist.txt
```
📚 Hasher Indexer
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Elasticsearch: http://localhost:9200
Index: hasher
Redis: localhost:6379
File: sample-wordlist.txt
Batch size: 100
Duplicate check: enabled
🔗 Connecting to Elasticsearch...
🔗 Connecting to Redis...
✅ Connected successfully
📖 Reading file...
✅ Found 20 words/phrases to process
⏳ Progress: 20/20 (100.0%) - Indexed: 20, Errors: 0
🔄 Refreshing index...
⏳ Progress: 20/20 (100.0%) - Indexed: 20, Skipped: 0, Errors: 0
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Indexing complete!
@@ -185,13 +191,13 @@ fetch('/api/search', {
- [ ] Results display correctly
### Data Persistence
- [ ] New plaintext is saved to Elasticsearch
- [ ] New plaintext is saved to Redis
- [ ] Saved hashes can be found in subsequent searches
- [ ] Bulk indexing saves all entries
- [ ] Index is created automatically if missing
- [ ] Redis keys are created with proper patterns
### Error Handling
- [ ] Elasticsearch connection errors are handled
- [ ] Redis connection errors are handled
- [ ] Empty search queries are prevented
- [ ] Invalid input is handled gracefully
- [ ] Network errors show user-friendly messages
@@ -200,15 +206,16 @@ fetch('/api/search', {
## 🐛 Common Issues & Solutions
### Issue: Cannot connect to Elasticsearch
### Issue: Cannot connect to Redis
**Solution**:
```bash
# Check if Elasticsearch is running
curl http://localhost:9200
# Check if Redis is running
redis-cli ping
# If not accessible, update the environment variable
export ELASTICSEARCH_NODE=http://your-elasticsearch-host:9200
# If not accessible, update the environment variables
export REDIS_HOST=localhost
export REDIS_PORT=6379
npm run dev
```
@@ -242,33 +249,34 @@ npm run index-file -- "$(pwd)/sample-wordlist.txt"
---
## 📊 Verify Data in Elasticsearch
## 📊 Verify Data in Redis
### Check Index Stats
### Check Database Size
```bash
curl http://localhost:9200/hasher/_stats?pretty
redis-cli DBSIZE
```
### Count Documents
### Get Statistics
```bash
curl http://localhost:9200/hasher/_count?pretty
redis-cli HGETALL hash:stats
```
### View Sample Documents
```bash
curl http://localhost:9200/hasher/_search?pretty&size=5
# List first 10 document keys
redis-cli --scan --pattern "hash:plaintext:*" | head -10
# Get a specific document
redis-cli GET "hash:plaintext:password"
```
### Search Specific Hash
```bash
curl http://localhost:9200/hasher/_search?pretty -H 'Content-Type: application/json' -d'
{
"query": {
"term": {
"md5": "5f4dcc3b5aa765d61d8327deb882cf99"
}
}
}'
# Find document by MD5 hash
redis-cli GET "hash:index:md5:5f4dcc3b5aa765d61d8327deb882cf99"
# Then get the full document
redis-cli GET "hash:plaintext:password"
```
---
@@ -329,7 +337,7 @@ Create `search.json`:
- [ ] CORS configuration
- [ ] Rate limiting (if implemented)
- [ ] Error message information disclosure
- [ ] Elasticsearch authentication (if enabled)
- [ ] Redis authentication (if enabled)
---
@@ -339,7 +347,7 @@ Before deploying to production:
- [ ] All tests passing
- [ ] Environment variables configured
- [ ] Elasticsearch secured and backed up
- [ ] Redis secured and backed up (RDB/AOF)
- [ ] SSL/TLS certificates installed
- [ ] Error logging configured
- [ ] Monitoring set up
@@ -357,7 +365,7 @@ Before deploying to production:
## Environment
- Node.js version:
- Elasticsearch version:
- Redis version:
- Browser(s) tested:
## Test Results