From 74fd6d80b06b9991e1f013efa4d35734d710aca3 Mon Sep 17 00:00:00 2001 From: zipped <73859069+bruhbruhroblox@users.noreply.github.com> Date: Sat, 2 Dec 2023 20:56:35 +0000 Subject: [PATCH] search fix --- backend/routers/filer.py | 6 ++---- backend/start.py | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/backend/routers/filer.py b/backend/routers/filer.py index 974d9b61..16e1e296 100644 --- a/backend/routers/filer.py +++ b/backend/routers/filer.py @@ -204,14 +204,12 @@ async def query_filer(cik: str, background: BackgroundTasks): @cache(24) @router.get("/search", tags=["filers"], status_code=200) async def search_filers(q: str, limit: int = 4): - options = {"limit": limit, "filter": ["thirteen_f = true"]} + options = {"limit": limit, "filter": "thirteen_f = true"} hits = search_companies(q, options) results = [] for result in hits: - result_names = list(map(lambda n: n["name"], results)) - if result["name"] not in result_names: - results.append(result) + results.append(result) return {"description": "Successfully queried 13F filers.", "results": hits} diff --git a/backend/start.py b/backend/start.py index 096bff6a..4f474d4c 100644 --- a/backend/start.py +++ b/backend/start.py @@ -85,9 +85,9 @@ def main(): retries = 3 while retries: search = meilisearch.Client(MEILI_SERVER_URL, MEILI_MASTER_KEY) - search.create_index("companies") - companies_index = search.index("companies", {"primaryKey": "cik"}) - companies_index.add_documents([{"name": "TEST"}]) + search.create_index("companies", {"primaryKey": "cik"}) + companies_index = search.index("companies") + companies_index.add_documents([{"cik": "TEST"}]) retries -= 1 raise RuntimeError except: @@ -98,7 +98,7 @@ def main(): db_empty = True if companies.count_documents({}) == 0 else False search_empty = ( - True if companies_index.get_stats().number_of_documents == 0 else False + True if companies_index.get_stats().number_of_documents == 1 else False ) backup_path = "./public/backup"