Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 26, 2025

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 property
  • related_synonyms - Returns related synonyms from hasRelatedSynonym property
  • narrow_synonyms - Returns narrow synonyms from hasNarrowSynonym property
  • broad_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 synonym field 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 synonym field 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)

Fixes #993

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Return synonyms in v1 search endpoint Add split synonym types to v1 search endpoint Sep 26, 2025
Copilot finished work on behalf of jamesamcl September 26, 2025 15:33
Copilot AI requested a review from jamesamcl September 26, 2025 15:33
@cthoyt
Copy link
Contributor

cthoyt commented Oct 16, 2025

If you're going to update this field, you might want to start returning synonym types in addition to the text itself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Return synonyms in v1 search endpoint

3 participants