Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

feat: add Elasticsearch configuration to web UI and implement modular settings

LearningCircuitabb4c8cb0017
diff --git a/examples/elasticsearch_search_example.py b/examples/elasticsearch_search_example.py
index 824ce68c6e..f7285e7cf3 100644
--- a/examples/elasticsearch_search_example.py
+++ b/examples/elasticsearch_search_example.py
@@ -28,7 +28,7 @@ def index_sample_documents():
# 创建 Elasticsearch 管理器 (Create Elasticsearch manager)
es_manager = ElasticsearchManager(
- hosts=["http://172.16.4.131:9200"],
+ hosts=["http://localhost:9200"],
# 如果需要可以提供认证信息 (Authentication credentials can be provided if needed)
# username="elastic",
# password="password",
@@ -90,7 +90,7 @@ def search_documents(index_name, query):
# 创建 Elasticsearch 搜索引擎 (Create Elasticsearch search engine)
search_engine = ElasticsearchSearchEngine(
- hosts=["http://172.16.4.131:9200"],
+ hosts=["http://localhost:9200"],
index_name=index_name,
max_results=10,
# 如果需要可以提供认证信息 (Authentication credentials can be provided if needed)
@@ -126,7 +126,7 @@ def advanced_search_examples(index_name):
# 创建 Elasticsearch 搜索引擎 (Create Elasticsearch search engine)
search_engine = ElasticsearchSearchEngine(
- hosts=["http://172.16.4.131:9200"],
+ hosts=["http://localhost:9200"],
index_name=index_name,
)
diff --git a/src/local_deep_research/defaults/settings/search_engines/elasticsearch.json b/src/local_deep_research/defaults/settings/search_engines/elasticsearch.json
new file mode 100644
index 0000000000..719908d480
--- /dev/null
+++ b/src/local_deep_research/defaults/settings/search_engines/elasticsearch.json
@@ -0,0 +1,282 @@
+{
+ "search.engine.web.elasticsearch.display_name": {
+ "category": "elasticsearch",
+ "description": "Display name to use in the U.I. for this search engine.",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Display Name",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "Elasticsearch",
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.description": {
+ "category": "elasticsearch",
+ "description": "Human-readable description of the search engine.",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Description",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "Search engine for Elasticsearch databases. Efficient for searching document collections and structured data.",
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.class_name": {
+ "category": "elasticsearch",
+ "description": "Setting for elasticsearch.class_name",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Class Name",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "ElasticsearchSearchEngine",
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.module_path": {
+ "category": "elasticsearch",
+ "description": "Setting for elasticsearch.module_path",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Module Path",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "local_deep_research.web_search_engines.engines.search_engine_elasticsearch",
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.default_params.hosts": {
+ "category": "elasticsearch",
+ "description": "Elasticsearch server URLs (JSON array format)",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Elasticsearch Host URLs",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": "[\"http://localhost:9200\"]",
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.default_params.index_name": {
+ "category": "elasticsearch",
+ "description": "Name of the Elasticsearch index to search",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Index Name",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "documents",
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.default_params.username": {
+ "category": "elasticsearch",
+ "description": "Username for Elasticsearch authentication (optional)",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Username",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "",
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.default_params.password": {
+ "category": "elasticsearch",
+ "description": "Password for Elasticsearch authentication (optional)",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Password",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "password",
+ "value": "",
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.default_params.api_key": {
+ "category": "elasticsearch",
+ "description": "API key for Elasticsearch authentication (optional)",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "API Key",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "password",
+ "value": "",
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.default_params.cloud_id": {
+ "category": "elasticsearch",
+ "description": "Elastic Cloud ID for cloud-hosted Elasticsearch (optional)",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Cloud ID",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "",
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.default_params.max_results": {
+ "category": "elasticsearch",
+ "description": "Maximum number of search results to return",
+ "editable": true,
+ "max_value": 100,
+ "min_value": 1,
+ "name": "Max Results",
+ "options": null,
+ "step": 1,
+ "type": "SEARCH",
+ "ui_element": "number",
+ "value": 10,
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.default_params.search_fields": {
+ "category": "elasticsearch",
+ "description": "Fields to search in (JSON array)",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Search Fields",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": "[\"content\", \"title\", \"description\", \"text\"]",
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.default_params.highlight_fields": {
+ "category": "elasticsearch",
+ "description": "Fields to highlight in search results (JSON array)",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Highlight Fields",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": "[\"content\", \"title\"]",
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.reliability": {
+ "category": "elasticsearch",
+ "description": "Reliability of the Elasticsearch search engine",
+ "editable": true,
+ "max_value": 1.0,
+ "min_value": 0.0,
+ "name": "Reliability",
+ "options": null,
+ "step": 0.05,
+ "type": "SEARCH",
+ "ui_element": "range",
+ "value": 0.95,
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.requires_api_key": {
+ "category": "elasticsearch",
+ "description": "Whether this search engine requires an API key",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Requires Api Key",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": false,
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.requires_llm": {
+ "category": "elasticsearch",
+ "description": "Whether this search engine requires an LLM for relevance filtering",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Requires LLM",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": true,
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.supports_full_search": {
+ "category": "elasticsearch",
+ "description": "Whether this search engine supports full document search",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Supports Full Search",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": true,
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.strengths": {
+ "category": "elasticsearch",
+ "description": "Strengths of this search engine",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Strengths",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": "[\"Fast full-text search\", \"Scalable and distributed\", \"Rich query DSL\", \"Supports aggregations\", \"Real-time search\"]",
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.weaknesses": {
+ "category": "elasticsearch",
+ "description": "Weaknesses of this search engine",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Weaknesses",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": "[\"Requires running Elasticsearch instance\", \"Needs proper index configuration\", \"Data must be pre-indexed\"]",
+ "visible": true
+ },
+ "search.engine.web.elasticsearch.use_in_auto_search": {
+ "category": "elasticsearch",
+ "description": "Include Elasticsearch in auto search mode",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Include in Auto Search",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": false,
+ "visible": true
+ }
+}
diff --git a/src/local_deep_research/web/services/settings_manager.py b/src/local_deep_research/web/services/settings_manager.py
index c610db2cbd..8fd94a0d59 100644
--- a/src/local_deep_research/web/services/settings_manager.py
+++ b/src/local_deep_research/web/services/settings_manager.py
@@ -2,6 +2,7 @@ import importlib.resources as pkg_resources
import json
import os
import threading
+from pathlib import Path
from typing import Any, Dict, List, Optional, Type, Union
from loguru import logger
@@ -104,13 +105,83 @@ class SettingsManager:
def default_settings(self) -> Dict[str, Any]:
"""
Returns:
- The default settings, loaded from JSON.
+ The default settings, loaded from JSON files and merged.
+ Automatically discovers and loads all .json files in the defaults directory
+ and its subdirectories.
"""
- default_settings = pkg_resources.read_text(
- defaults, "default_settings.json"
- )
- return json.loads(default_settings)
+ settings = {}
+
+ # Load main settings file first (if it exists)
+ try:
+ main_settings = pkg_resources.read_text(
+ defaults, "default_settings.json"
+ )
+ settings.update(json.loads(main_settings))
+ logger.debug("Loaded main default_settings.json")
+ except Exception as e:
+ logger.info(
+ f"No main default_settings.json found (this is OK): {e}"
+ )
+
+ # Get the defaults package path
+ try:
+ defaults_path = Path(defaults.__file__).parent
+
+ # Recursively find and load all JSON files in the defaults directory
+ # excluding the main default_settings.json which we already loaded
+ json_files = []
+
+ # Check if settings subdirectory exists
+ settings_dir = defaults_path / "settings"
+ if settings_dir.exists():
+ # Use rglob to recursively find all .json files
+ json_files = list(settings_dir.rglob("*.json"))
+
+ # Sort files to ensure consistent loading order
+ json_files.sort()
+
+ logger.info(
+ f"Found {len(json_files)} additional JSON settings files to load"
+ )
+
+ # Load each JSON file and merge into settings
+ for json_file in json_files:
+ try:
+ with open(json_file, "r") as f:
+ file_settings = json.load(f)
+
+ # Get relative path for logging
+ relative_path = json_file.relative_to(defaults_path)
+
+ # Check for key conflicts
+ conflicts = set(settings.keys()) & set(
+ file_settings.keys()
+ )
+ if conflicts:
+ logger.warning(
+ f"Keys {conflicts} from {relative_path} will override existing values"
+ )
+
+ settings.update(file_settings)
+ logger.debug(
+ f"Loaded settings from {relative_path}"
+ )
+
+ except json.JSONDecodeError:
+ logger.exception(f"Invalid JSON in {json_file}")
+ except Exception as e:
+ logger.warning(f"Could not load {json_file}: {e}")
+ else:
+ logger.debug(
+ "No settings subdirectory found, using only main settings file"
+ )
+
+ except Exception as e:
+ logger.warning(f"Error loading modular settings files: {e}")
+
+ logger.info(f"Loaded total of {len(settings)} settings")
+ return settings
def __get_typed_setting_value(
self,
diff --git a/src/local_deep_research/web_search_engines/search_engines_config.py b/src/local_deep_research/web_search_engines/search_engines_config.py
index 896e9a21a0..6a4aae6b4d 100644
--- a/src/local_deep_research/web_search_engines/search_engines_config.py
+++ b/src/local_deep_research/web_search_engines/search_engines_config.py
@@ -11,7 +11,6 @@ from loguru import logger
from ..config.thread_settings import get_setting_from_snapshot
from ..utilities.db_utils import get_settings_manager
-from .default_search_engines import get_default_elasticsearch_config
def _get_setting(
@@ -154,11 +153,6 @@ def search_config(
if "auto" in search_engines and "meta" not in search_engines:
search_engines["meta"] = search_engines["auto"]
- # Add Elasticsearch search engine if not already present
- if "elasticsearch" not in search_engines:
- logger.info("Adding default Elasticsearch search engine configuration")
- search_engines["elasticsearch"] = get_default_elasticsearch_config()
-
# Register local document collections
local_collections_data = _get_setting(
"search.engine.local",