From 2e052913b6d473480cdf1e2ef8e18375157d96ac Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Tue, 7 Feb 2023 02:31:35 -0300 Subject: [PATCH] Search in first configured content type when no search type set Instead of searching through all configured content types but only returning results of the last configured content type --- src/routers/api.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/routers/api.py b/src/routers/api.py index c505c133..f759a27d 100644 --- a/src/routers/api.py +++ b/src/routers/api.py @@ -64,7 +64,7 @@ def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None, r: Opti with timer("Collating results took", logger): results = text_search.collate_results(hits, entries, results_count) - if (t == SearchType.Music or t == None) and state.model.music_search: + elif (t == SearchType.Music or t == None) and state.model.music_search: # query music library with timer("Query took", logger): hits, entries = text_search.query(user_query, state.model.music_search, rank_results=r) @@ -73,7 +73,7 @@ def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None, r: Opti with timer("Collating results took", logger): results = text_search.collate_results(hits, entries, results_count) - if (t == SearchType.Markdown or t == None) and state.model.markdown_search: + elif (t == SearchType.Markdown or t == None) and state.model.markdown_search: # query markdown files with timer("Query took", logger): hits, entries = text_search.query(user_query, state.model.markdown_search, rank_results=r) @@ -82,7 +82,7 @@ def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None, r: Opti with timer("Collating results took", logger): results = text_search.collate_results(hits, entries, results_count) - if (t == SearchType.Ledger or t == None) and state.model.ledger_search: + elif (t == SearchType.Ledger or t == None) and state.model.ledger_search: # query transactions with timer("Query took", logger): hits, entries = text_search.query(user_query, state.model.ledger_search, rank_results=r) @@ -91,7 +91,7 @@ def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None, r: Opti with timer("Collating results took", logger): results = text_search.collate_results(hits, entries, results_count) - if (t == SearchType.Image or t == None) and state.model.image_search: + elif (t == SearchType.Image or t == None) and state.model.image_search: # query images with timer("Query took", logger): hits = image_search.query(user_query, results_count, state.model.image_search)