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

API function to find concept based on value #142

Closed
ManonGros opened this issue Jul 1, 2024 · 14 comments
Closed

API function to find concept based on value #142

ManonGros opened this issue Jul 1, 2024 · 14 comments
Assignees
Labels
enhancement New feature or request

Comments

@ManonGros
Copy link
Collaborator

It would be great to have an API function/endpoint where I can find which concept a value matches to for a given vocabulary.

For example, I would like to know which concept jeune matches to in the life stage vocabulary. Right now I have to query all the labels for all the concept until I find the right one.
Instead, I would like to be able to do something like https://api.gbif.org/v1/vocabularies/lifeStage/match?q=jeune and be returned the concept for which the value matches (the value should be matched to any of the hidden or alternative or translation labels).

@ManonGros ManonGros added the enhancement New feature or request label Jul 1, 2024
@CecSve
Copy link
Collaborator

CecSve commented Jul 1, 2024

This would be very helpful for users and institutions that may want to use a vocabulary to map their data prior to sharing it with GBIF

@marcos-lg
Copy link
Contributor

We have a basic full-text search: https://api.gbif.org/v1/vocabularies/LifeStage/concepts?q=joven

I think jeune is not present in any label.

@ManonGros
Copy link
Collaborator Author

I am confused by that function, if use https://api.gbif.org/v1/vocabularies/Sex/concepts?q=male, I get several concepts. Is there a way to find the concept that the value male would match to?

@CecSve
Copy link
Collaborator

CecSve commented Aug 22, 2024

I am confused by that function, if use https://api.gbif.org/v1/vocabularies/Sex/concepts?q=male, I get several concepts. Is there a way to find the concept that the value male would match to?

You get all the concepts of the vocabulary, it seems. Ideally, you should only get the concept that the verbatim value maps to (if the hidden value exists of course)

@marcos-lg
Copy link
Contributor

That is a free-text search that matches any concept that has that value. I think what you want is a lookup endpoint but we don't have it (pipelines does a lookup but it's not an API endpoint). We could add it though.

@ManonGros
Copy link
Collaborator Author

I think having a lookup would be really helpful.

@CecSve
Copy link
Collaborator

CecSve commented Aug 26, 2024

I think having a lookup would be really helpful.

+1

marcos-lg added a commit that referenced this issue Sep 6, 2024
@marcos-lg
Copy link
Contributor

marcos-lg commented Sep 10, 2024

I deployed a lookup endpoint in UAT.

It returns only the fields that match, for example, this matched the concept name:

https://api.gbif-uat.org/v1/vocabularies/LifeStage/concepts/lookup?q=adult

This matched the spanish label:

https://api.gbif-uat.org/v1/vocabularies/LifeStage/concepts/lookup?q=adulto

this matched a hidden label:

https://api.gbif-uat.org/v1/vocabularies/LifeStage/concepts/lookup?q=A

this matched an alternative label:

https://api.gbif-uat.org/v1/vocabularies/LifeStage/concepts/lookup?q=Newborn

you can also filter by language:

https://api.gbif-uat.org/v1/vocabularies/LifeStage/concepts/lookup?q=adulto&lang=PT-pt
https://api.gbif-uat.org/v1/vocabularies/LifeStage/concepts/lookup?q=adulto&lang=ES-es

and if the value is not found in that language but exists in English, the English match is returned:

https://api.gbif-uat.org/v1/vocabularies/LifeStage/concepts/lookup?q=newborn&lang=ES-es

@CecSve @ManonGros are you missing something or is there anything you want to change?

EDIT: I renamed the param to q

marcos-lg added a commit that referenced this issue Sep 10, 2024
@marcos-lg marcos-lg self-assigned this Sep 10, 2024
@ManonGros
Copy link
Collaborator Author

Thanks @marcos-lg ! This looks great!
I have been trying to lookup a few things and found that this one: https://api.gbif-uat.org/v1/vocabularies/GeoTime/concepts/lookup?q=přídol doesn't give me what I expect (which would be https://api.gbif-uat.org/v1/vocabularies/GeoTime/concepts/Pridoli). Is it because of the ří?

(This works for example: https://api.gbif-uat.org/v1/vocabularies/GeoTime/concepts/lookup?q=pridolij)

@marcos-lg
Copy link
Contributor

I replace non-ascii characters with their equivalents but it seems that pridol doesn't exist. This works:

https://api.gbif-uat.org/v1/vocabularies/GeoTime/concepts/lookup?q=přídoli

@ManonGros
Copy link
Collaborator Author

Ha! Yes I probably did some wrong copy/pasting. Thanks for checking Marcos! The lookup looks good, it will be very helpful to have.

marcos-lg added a commit that referenced this issue Sep 11, 2024
(cherry picked from commit ceb4027)
marcos-lg added a commit that referenced this issue Sep 11, 2024
(cherry picked from commit 7027e04)
marcos-lg added a commit that referenced this issue Sep 11, 2024
marcos-lg added a commit that referenced this issue Sep 11, 2024
@marcos-lg
Copy link
Contributor

@marcos-lg
Copy link
Contributor

Forgot to mention that this also works for the latestRelease endpoints, e.g.: https://api.gbif.org/v1/vocabularies/LifeStage/concepts/latestRelease/lookup?q=adulto

@CecSve
Copy link
Collaborator

CecSve commented Sep 12, 2024

Thank you! This super useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants