Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return entire document in reverse lookups #115

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ class Request(BaseModel):
"/reverse_lookup",
summary="Look up synonyms for a CURIE.",
description="Returns a list of synonyms for a particular CURIE.",
response_model=Dict[str, List[str]],
response_model=Dict[str, Dict],
tags=["lookup"],
)
async def lookup_names_get(
curies: List[str]= Query(
example=["MONDO:0005737", "MONDO:0009757"],
description="A list of CURIEs to look up synonyms for."
)
) -> Dict[str, List[str]]:
) -> Dict[str, Dict]:
"""Returns a list of synonyms for a particular CURIE."""
return await reverse_lookup(curies)

Expand All @@ -70,7 +70,7 @@ async def lookup_names_get(
"/reverse_lookup",
summary="Look up synonyms for a CURIE.",
description="Returns a list of synonyms for a particular CURIE.",
response_model=Dict[str, List[str]],
response_model=Dict[str, Dict],
tags=["lookup"],
)
async def lookup_names_post(
Expand All @@ -82,7 +82,7 @@ async def lookup_names_post(
return await reverse_lookup(request.curies)


async def reverse_lookup(curies) -> Dict[str, List[str]]:
async def reverse_lookup(curies) -> Dict[str, Dict]:
"""Returns a list of synonyms for a particular CURIE."""
query = f"http://{SOLR_HOST}:{SOLR_PORT}/solr/name_lookup/select"
curie_filter = " OR ".join(
Expand All @@ -102,7 +102,7 @@ async def reverse_lookup(curies) -> Dict[str, List[str]]:
for curie in curies
}
for doc in response_json["response"]["docs"]:
output[doc["curie"]].extend(doc["names"])
output[doc["curie"]] = doc
return output

class LookupResult(BaseModel):
Expand Down
Loading