From df765294283b90e76dfc12569a6f70b43e4e6934 Mon Sep 17 00:00:00 2001 From: RhodeCode Admin Date: Wed, 4 Jun 2025 08:43:07 +0200 Subject: [PATCH] search: added deprecation for whoosh searcher --- rhodecode/lib/index/__init__.py | 7 ++++++- rhodecode/lib/index/whoosh.py | 29 +++++++---------------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/rhodecode/lib/index/__init__.py b/rhodecode/lib/index/__init__.py index 55e4ece8..833aef02 100644 --- a/rhodecode/lib/index/__init__.py +++ b/rhodecode/lib/index/__init__.py @@ -147,6 +147,11 @@ def searcher_from_config(config, prefix="search."): # use an old legacy ES version set to 8 _config["es_version"] = DEFAULT_ES_VERSION - imported = importlib.import_module(_config.get("module", default_searcher)) + search_module = _config.get("module", default_searcher) + if search_module == "rhodecode.lib.index.whoosh": + log.warning("rhodecode.lib.index.whoosh module is no longer supported, using default searcher rc_elasticsearch") + search_module = "rc_elasticsearch" + + imported = importlib.import_module(search_module) searcher = imported.Searcher(config=_config) return searcher diff --git a/rhodecode/lib/index/whoosh.py b/rhodecode/lib/index/whoosh.py index b3c2963a..31a4cc78 100644 --- a/rhodecode/lib/index/whoosh.py +++ b/rhodecode/lib/index/whoosh.py @@ -36,28 +36,13 @@ from rhodecode.lib.str_utils import safe_str log = logging.getLogger(__name__) -try: - # we first try to import from rhodecode tools, fallback to copies if - # we're unable to - from rhodecode_tools.lib.fts_index.whoosh_schema import ( - ANALYZER, - FILE_INDEX_NAME, - FILE_SCHEMA, - COMMIT_INDEX_NAME, - COMMIT_SCHEMA, - ) -except ImportError: - log.warning( - "rhodecode_tools schema not available, doing a fallback " - "import from `rhodecode.lib.index.whoosh_fallback_schema`" - ) - from rhodecode.lib.index.whoosh_fallback_schema import ( - ANALYZER, - FILE_INDEX_NAME, - FILE_SCHEMA, - COMMIT_INDEX_NAME, - COMMIT_SCHEMA, - ) +from rhodecode.lib.index.whoosh_fallback_schema import ( + ANALYZER, + FILE_INDEX_NAME, + FILE_SCHEMA, + COMMIT_INDEX_NAME, + COMMIT_SCHEMA, +) FORMATTER = HtmlFormatter("span", between='\n...\n')