Add split synonym types to v1 search endpoint #994
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR addresses the issue "Return synonyms in v1 search endpoint" by adding support for returning synonyms split into different OBO synonym types while maintaining full backward compatibility.
Changes Made
The v1 search API (
/api/search) now supports four new optional fields in thefieldListparameter:exact_synonyms- Returns exact synonyms from hasExactSynonym propertyrelated_synonyms- Returns related synonyms from hasRelatedSynonym propertynarrow_synonyms- Returns narrow synonyms from hasNarrowSynonym propertybroad_synonyms- Returns broad synonyms from hasBroadSynonym propertyUsage Examples
Request specific synonym types:
Response:
{ "response": { "docs": [ { "iri": "http://example.org/disease", "label": "Disease", "exact_synonyms": ["illness", "disorder"], "related_synonyms": ["sickness"] } ] } }Backward compatibility maintained:
Response (unchanged):
{ "response": { "docs": [ { "iri": "http://example.org/disease", "label": "Disease", "synonym": ["illness", "disorder", "sickness"] } ] } }Technical Details
synonymfield remains completely unchangedfieldListsynonymfield formatFiles Changed
backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1SearchController.java- Added handling for new synonym type fields and updated API documentationThe implementation is minimal and surgical, requiring only a few lines of code to expose the synonym categorization that was already present in the data but not accessible through the search API.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.