EBISPOT / ols4

Version 4 of the EMBL-EBI Ontology Lookup Service (OLS)
http://www.ebi.ac.uk/ols4/
Apache License 2.0
44 stars 18 forks source link

Return annotations in search endpoint via `fieldList` #560

Open marius-mather opened 11 months ago

marius-mather commented 11 months ago

In the OLS3 search API it was possible to request individual annotation fields be included in the results via fieldList. You could either include annotations_trimmed, or specify an annotation by including <field_name>_annotation in fieldList.

Example OLS3 request:

https://www.ebi.ac.uk/ols/api/search?q=holstein&ontology=vbo&queryFields=label,synonym&fieldList=iri,label,synonym,subset,exists_in_country_annotation,annotations_trimmed

This would return result items like:

 {
    "iri": "http://purl.obolibrary.org/obo/VBO_0003160",
    "label": "Holstein, Ecuador (Cattle)",
    "synonym": [
        "Holstein"
    ],
    "annotations_trimmed": [
        "https://orcid.org/0000-0002-4142-7153",
        "https://orcid.org/0000-0002-5520-6597",
        "https://orcid.org/0000-0002-9178-3965",
        "http://www.wikidata.org/entity/Q736",
        "https://www.fao.org/dad-is",
        "ECU"
    ],
    "exists_in_country_annotation": [
        "http://www.wikidata.org/entity/Q736"
    ]
}

Currently, neither form of the annotation seems to be supported in OLS4.

Including these annotations in search results is very useful for my use case because it means I can search for multiple results, without having to do individual requests on each term when I need to filter on one of these annotation properties.

jamesamcl commented 11 months ago

I am looking into reimplementing annotations_trimmed to enhance the search boosting, but interested in your use case for returning them to the API consumer? Aren't the annotations values pretty much useless without the properties they correspond to?

henrietteharmse commented 11 months ago

This is an undocumented feature in OLS3 and was not intended to be used in this way. Having said that, this could be an interesting use case and is worth exploring further.

marius-mather commented 11 months ago

Yes, I've never found having annotations_trimmed in the returned fields that useful, because you can't see what fields they correspond to. But the undocumented feature in OLS3 where you could request specific annotations turned out to be very useful, as 1 or 2 extra fields in the search result items can mean the difference between just using the search results, and having to do individual lookups of every term.

Possibly I only discovered this by reading the OLS3 source code, after trying to work out which annotations could actually be retrieved in the search endpoint. So I've made life hard for myself by relying on an undocumented feature. I've attempted a pull request for retrieving the specific annotations in #561