2828from .indexer import SearchIndexer , SemanticSearchIndexer , SearchIndexerBase
2929from .embeddings import embedding_function_factory
3030
31- _KEY_INDEXER = "_SEARCH_INDEXER"
32- _KEY_INDEXER_SEMANTIC = "_SEARCH_INDEXER_SEMANTIC"
33-
3431
3532def get_search_indexer (tree : str , semantic : bool = False ) -> SearchIndexerBase :
3633 """Get the search indexer for the tree."""
3734 # return cached instances if possible
38- if not semantic and (indexer := current_app .config .get (_KEY_INDEXER )):
39- return indexer
40- if semantic and (indexer := current_app .config .get (_KEY_INDEXER_SEMANTIC )):
41- return indexer
4235 db_url = current_app .config ["SEARCH_INDEX_DB_URI" ] or None
4336 if not db_url and current_app .config ["SEARCH_INDEX_DIR" ]:
4437 # backwards compatibility...
@@ -65,10 +58,7 @@ def get_search_indexer(tree: str, semantic: bool = False) -> SearchIndexerBase:
6558 except OSError :
6659 raise ValueError (f"Failed initializing model { model } " )
6760 # cache on app instance
68- current_app . config [ _KEY_INDEXER_SEMANTIC ] = SemanticSearchIndexer (
61+ return SemanticSearchIndexer (
6962 db_url = db_url , tree = tree , embedding_function = embedding_function
7063 )
71- return current_app .config [_KEY_INDEXER_SEMANTIC ]
72- # cache on app instance
73- current_app .config [_KEY_INDEXER ] = SearchIndexer (db_url = db_url , tree = tree )
74- return current_app .config [_KEY_INDEXER ]
64+ return SearchIndexer (db_url = db_url , tree = tree )
0 commit comments