ols4
ols4 copied to clipboard
Add split synonym types to v1 search endpoint
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 the fieldList parameter:
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 property
Usage Examples
Request specific synonym types:
GET /api/search?q=disease&fieldList=iri,label,exact_synonyms,related_synonyms
Response:
{
"response": {
"docs": [
{
"iri": "http://example.org/disease",
"label": "Disease",
"exact_synonyms": ["illness", "disorder"],
"related_synonyms": ["sickness"]
}
]
}
}
Backward compatibility maintained:
GET /api/search?q=disease&fieldList=iri,label,synonym
Response (unchanged):
{
"response": {
"docs": [
{
"iri": "http://example.org/disease",
"label": "Disease",
"synonym": ["illness", "disorder", "sickness"]
}
]
}
}
Technical Details
- Zero Breaking Changes: The existing
synonymfield remains completely unchanged - On-Demand Fields: New synonym type fields are only included when explicitly requested in
fieldList - Leverages Existing Data: Uses the OBO synonym categorization already stored in the system through existing JsonHelper methods
- Consistent Format: Returns arrays of strings matching the existing
synonymfield format
Files 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 documentation
The 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
This section details on the original issue you should resolve
<issue_title>Return synonyms in v1 search endpoint</issue_title> <issue_description>Should be split into different types of synonym </issue_description>
Comments on the Issue (you are @copilot in this section)
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.