Skip to content

Commit

Permalink
search fix
Browse files Browse the repository at this point in the history
  • Loading branch information
leftmove authored Dec 2, 2023
1 parent 40c0d29 commit 74fd6d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions backend/routers/filer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
8 changes: 4 additions & 4 deletions backend/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"

Expand Down

0 comments on commit 74fd6d8

Please sign in to comment.