简介
Welcome to SearXNG --- SearXNG Documentation (2025.3.29+50f92779b) SearXNG 是一个免费的互联网元搜索引擎,可聚合多达 231 个搜索服务的结果。用户不会被追踪或分析。此外,SearXNG 可以通过 Tor 使用,以保证在线匿名性。通过使用 searx.space 上列出的实例开始使用 SearXNG。如果您不信任任何人,您可以搭建自己的实例。
安装
自建部署 SearXNG (推荐)
最佳使用方式:强烈建议您自托管自己的 SearXNG 实例:
使用 Docker
arduino
# Pull the SearXNG Docker image
docker pull searxng/searxng
# Run SearXNG (will be available at http://localhost:8080)
docker run -d -p 8080:8080 --name searxng searxng/searxng
使用 Docker Compose (推荐)
可以 clone GitHub - searxng/searxng-docker: The docker-compose files for setting up a SearXNG instance with docker. 使用其中的 docker-compose.yml,或者手动编辑。
- 创建
docker-compose.yml
,输入下面内容
yaml
version: '3'
services:
searxng:
container_name: searxng
image: searxng/searxng
ports:
- "8080:8080"
volumes:
- ./searxng:/etc/searxng
environment:
- SEARXNG_BASE_URL=http://localhost:8080/
restart: unless-stopped
-
后台运行 Docker Compose:
docker-compose up -d
使用公开服务实例
如果你必须使用公开服务实例
- Get Permission: 始终联系任何公共实例的管理员
- Respect Resources: 在请求之间使用更长的延迟(至少 4-5 秒)
- Limited Usage: 尽量在有必要时才 search
公有实例的示例配置:
ini
SEARXNG_INSTANCE=https://instance.example.com
SEARXNG_DELAY=5.0
配置
配置文件在 searxng/settings.yml
输出格式配置
yaml
# remove format to deny access, use lower case.
# formats: [html, csv, json, rss]
formats:
- html
- json
查询参数中增加 format=json ,则会使用 json 格式返回查询结果
bash
[localhost:8081/search?format=json&q=Hello](http://localhost:8081/search?format=json&q=Hello)
local-deep-research 中配置 searXNG
local-deep-research/docs/SearXNG-Setup.md at main · LearningCircuit/local-deep-research · GitHub
Setting Up Access
You have two ways to enable the SearXNG search engine:
-
Environment Variable (Recommended) :
ini# Add to your .env file or set in your environment SEARXNG_INSTANCE=http://localhost:8080 # Optional: Set custom delay between requests (in seconds) SEARXNG_DELAY=2.0
-
Configuration Parameter : Add to your
config.py
:makefile# In config.py SEARXNG_CONFIG = { "instance_url": "http://localhost:8080", "delay_between_requests": 2.0 }
Checking Configuration
To verify if SearXNG is properly configured:
python
from local_deep_research.web_search_engines.search_engine_factory import create_search_engine
from local_deep_research.web_search_engines.search_engines_config import SEARCH_ENGINES
# Create the engine
engine = create_search_engine("searxng")
# Check if available
if engine and hasattr(engine, 'is_available') and engine.is_available:
print(f"SearXNG configured with instance: {engine.instance_url}")
print(f"Delay between requests: {engine.delay_between_requests} seconds")
else:
print("SearXNG is not properly configured or is disabled")
结果是找不到 searXNG
sql
local_deep_research.web_search_engines.search_engine_factory:Search engine 'searxng' not found, using default: wikipedia
INFO:local_deep_research.web_search_engines.search_engine_factory:Creating wikipedia with filtered parameters: dict_keys(['max_results', 'include_content'])
search_engines.toml
搜索引擎配置文件中,未添加 searxng 配置
ini
[searxng]
module_path = "local_deep_research.web_search_engines.engines.search_engine_searxng"
class_name = "SearXNGSearchEngine"
requires_api_key = false
reliability = 0.95
strengths = [
"web search", "product information", "reviews", "recent information",
"news", "general queries", "broad coverage"
]
weaknesses = ["inconsistent due to rate limits", "not specialized for academic content"]
[searxng.default_params]
format = json
python module load
ini
module = importlib.import_module(module_path)
engine_class = getattr(module, class_name)
local_deep_research.web_search_engines.engines.search_engine_searxng module 路径错误, 查看 local_deep_research.web_search_engines.engines.search_engine_searxng 文件,文件存在,但其中有 import 报错, 将 import 报错的引用增加 local_deep_research.
diff
(deep-researcher) λ git diff
diff --git a/src/local_deep_research/web_search_engines/engines/full_search.py b/src/local_deep_research/web_searc
_engines/engines/full_search.py
index 8b5a0cb..02d0744 100644
--- a/src/local_deep_research/web_search_engines/engines/full_search.py
+++ b/src/local_deep_research/web_search_engines/engines/full_search.py
@@ -4,7 +4,7 @@ from langchain_community.document_transformers import BeautifulSoupTransformer
from langchain_core.language_models import BaseLLM
from typing import List, Dict
import json, os
-from .utilties.search_utilities import remove_think_tags
+from local_deep_research.utilties.search_utilities import remove_think_tags
from datetime import datetime
from local_deep_research import config
import logging
diff --git a/src/local_deep_research/web_search_engines/engines/search_engine_searxng.py b/src/local_deep_research
web_search_engines/engines/search_engine_searxng.py
index 2ce1621..4561ebd 100644
--- a/src/local_deep_research/web_search_engines/engines/search_engine_searxng.py
+++ b/src/local_deep_research/web_search_engines/engines/search_engine_searxng.py
@@ -6,9 +6,9 @@ from langchain_core.language_models import BaseLLM
import time
import json
-from web_search_engines.search_engine_base import BaseSearchEngine
-from web_search_engines.engines.full_search import FullSearchResults
-import config
+from local_deep_research.web_search_engines.search_engine_base import BaseSearchEngine
+from local_deep_research.web_search_engines.engines.full_search import FullSearchResults
+from local_deep_research import config
# Setup logging
logging.basicConfig(level=logging.INFO)
diff --git a/tests/searxng_test.py b/tests/searxng_test.py
SEARXNG_INSTANCE
python
No SearXNG instance URL provided. The engine is disabled. Set SEARXNG_INSTANCE environment variable or provide instance_url parameter.
测试代码未加载环境变量配置 searXNG 的访问地址,修改测试代码加载 .env 环境变量配置文件。load_dotenv(dotenv_path=settings.env_file)
python
from local_deep_research.web_search_engines.search_engine_factory import create_search_engine
from local_deep_research.web_search_engines.search_engines_config import SEARCH_ENGINES
from local_deep_research.config import settings
from dotenv import load_dotenv
load_dotenv(dotenv_path=settings.env_file)
# Create the engine
engine = create_search_engine("searxng")
# Check if available
if engine and hasattr(engine, 'is_available') and engine.is_available:
print(f"SearXNG configured with instance: {engine.instance_url}")
print(f"Delay between requests: {engine.delay_between_requests} seconds")
else:
print("SearXNG is not properly configured or is disabled")
Done
less
INFO:local_deep_research.web_search_engines.search_engine_factory:Creating searxng with filtered parameters: dict_keys(['max_results'])
INFO:local_deep_research.web_search_engines.engines.search_engine_searxng:SearXNG init - Instance URL sources: api_key=None, env=http://localhost:8081, param=None
INFO:local_deep_research.web_search_engines.engines.search_engine_searxng:SearXNG initialized with instance URL: http://localhost:8081
INFO:local_deep_research.web_search_engines.engines.search_engine_searxng:SearXNG init params: max_results=50, language=en, max_filtered_results=None, is_available=True
INFO:local_deep_research.web_search_engines.engines.search_engine_searxng:SearXNG engine initialized with instance: http://localhost:8081
INFO:local_deep_research.web_search_engines.engines.search_engine_searxng:Rate limiting set to 2.0 seconds between requests
SearXNG configured with instance: http://localhost:8081
Delay between requests: 2.0 seconds