Basic query corrector for SearXNG server based on LanguageTool
632
A conservative compatibility service between the custom SearXNG query_corrector engine and a self-hosted LanguageTool server.
The shim:
POST /v1/correct with query and optional language;POST /v2/check;rule.issueType == "misspelling";/readyz and falls back to auto-detection for unsupported language codes;{"correction": null} whenever it cannot make a conservative correction;/healthz and /readyz.image: docker.io/erikvl87/languagetool:6.8
Merge the languagetool and query-corrector services from compose.example.yml into the existing SearXNG Compose file.
No host ports are required. Docker Compose DNS makes these internal addresses available:
http://languagetool:8010http://query-corrector:8000Then configure SearXNG:
use_default_settings: true
engines:
- name: query corrector
base_url: http://query-corrector:8000
enable_http: true
timeout: 1.0
inactive: false
disabled: false
The engine rejects plain HTTP unless enable_http: true is set. This is appropriate for the private Docker network shown above; use HTTPS for a remote service.
The bundled SearXNG engine timeout is 250 ms, so start with 1.0 second for this LanguageTool sidecar and tune after observing real latency.
Keep LANGUAGETOOL_TIMEOUT below the SearXNG engine timeout so the shim can return cleanly before SearXNG cancels its request. The initial LanguageTool request and the optional language=auto retry share this single timeout budget.
The Docker health check deliberately calls /readyz, not /healthz. The container is therefore marked unhealthy while LanguageTool is unavailable, even when the shim process itself is still serving requests.
| Variable | Default | Purpose |
|---|---|---|
LANGUAGETOOL_URL | http://languagetool:8010 | LanguageTool base URL |
LANGUAGETOOL_TIMEOUT | 0.8 | Upstream timeout in seconds |
DEFAULT_LANGUAGE | auto | Used when SearXNG sends no language |
PREFERRED_VARIANTS | en-US,de-DE,pt-PT | LanguageTool auto-detection variants |
LANGUAGE_VARIANTS | en:en-US,de:de-DE,pt:pt-PT | Variantless-language mappings |
IGNORED_WORDS | empty | Comma-separated technical terms |
MAX_QUERY_LENGTH | 80 | Maximum accepted query length |
MAX_CORRECTION_LENGTH | 256 | Maximum returned correction length |
MAX_EDITS | 2 | Maximum spelling edits per query |
MAX_TOKEN_EDIT_DISTANCE | 2 | Maximum edit distance per token |
MIN_TOKEN_LENGTH | 3 | Ignore shorter tokens |
ALLOW_WHITESPACE_REPLACEMENTS | false | Permit multiword suggestions while still requiring every part to be a plain word |
LOG_LEVEL | WARNING | Shim log level: CRITICAL, ERROR, WARNING, INFO, or DEBUG |
GitHub repo: https://github.com/fviolence/query-corrector
Content type
Image
Digest
sha256:1d564d958…
Size
47.6 MB
Last updated
about 1 month ago
docker pull fviolence/searxng-query-corrector