# SearXNG Deployment

Self-hosted metasearch engine — aggregates Google, Bing, DDG, etc. Hermes-native search backend. Privacy: all web searches go through your own instance instead of third-party API servers.

## Port: 8888 (bound to 127.0.0.1)

## Docker Compose

Location: `/mnt/seagate8tb/docker/searxng/docker-compose.yml`

```yaml
services:
  searxng:
    image: searxng/searxng:latest
    container_name: searxng
    ports:
      - "127.0.0.1:8888:8080"
    volumes:
      - ./searxng:/etc/searxng:rw
    environment:
      - SEARXNG_BASE_URL=http://localhost:8888/
    restart: unless-stopped
```

```bash
cd /mnt/seagate8tb/docker/searxng
docker compose up -d
```

## Enable JSON Format

SearXNG with `use_default_settings: true` has JSON disabled by default. The settings file is owned by the container user, so modify via docker exec:

```bash
docker exec searxng sh -c 'echo "search:" >> /etc/searxng/settings.yml && echo "  formats:" >> /etc/searxng/settings.yml && echo "    - html" >> /etc/searxng/settings.yml && echo "    - json" >> /etc/searxng/settings.yml'
docker restart searxng
```

Verify: `curl -s "http://localhost:8888/search?q=test&format=json" | python3 -c "import sys,json; d=json.load(sys.stdin); print(len(d['results']))"`

## Hermes Integration

```bash
# Add to ~/.hermes/.env
echo 'SEARXNG_URL=http://localhost:8888' >> ~/.hermes/.env

# Set search backend
hermes config set web.search_backend searxng
```

SearXNG is search-only — still need an extract backend (Firecrawl free tier) for `web_extract`.

## Maintenance

Google scraper breaks periodically when Google changes HTML. Fix: pull latest image and force-recreate:

```bash
cd /mnt/seagate8tb/docker/searxng
docker compose pull
docker compose up -d --force-recreate
```

Check for engine errors: `docker logs searxng 2>&1 | grep -i error | tail -10`

Rate limiting: Google may throttle with `SearxEngineTooManyRequestsException (suspended_time=180)`. This is normal — SearXNG falls back to other engines automatically.
