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

search taxon: show matched term when not scientific/preferred name #122

Open
synrg opened this issue Aug 2, 2020 · 0 comments
Open

search taxon: show matched term when not scientific/preferred name #122

synrg opened this issue Aug 2, 2020 · 0 comments
Labels
enhancement New feature or request inat 🍃 iNaturalist cog taxon iNaturalist taxa

Comments

@synrg
Copy link
Collaborator

synrg commented Aug 2, 2020

When a taxon search matches neither the scientific name nor the preferred name, ,search taxon should show the name that was actually matched in the search results, and also in the taxon display itself once the entry is selected. Compare:

image

and:

image

Cope's won't show for a ,t hyla versicolor query (because it correctly matches the Complex first), but without displaying the name, it is not apparent to people looking at the search results and/or pressing letter C to select it, why that even matched what the user typed.

The issue with the matched name not showing in the search results is that although format_taxon_name() (called in search.py get_taxon()) does pass with_term=True, that will only include the term if it is part of the taxon record, and for some reason with this particular query, it is not. Looking at the API call results:

https://api.inaturalist.org/v1/search?q=hyla%20versicolor&sources=taxa

It's returning this for the 3rd match:

    "matched_term": "Hyla chrysoscelis",

I don't think we can do any better! It might be worth asking an iNat dev why it returns this and not "Hyla versicolor", as expected.

But the issue with the matched name not showing in the selected entry is that it is displayed by calling the taxon() command itself on the taxon_id of the result, which does a whole separate search by id# instead of using search terms, so there's no way to get the terms communicated down to the taxon command. If the matched_term were correctly returned, what we should be doing instead to display a selected entry is taking the taxon record that was returned by the search and using that to populate the taxon embed with with_term=True, instead of looking it up again by taxon_id.

@synrg synrg added enhancement New feature or request inat 🍃 iNaturalist cog taxon iNaturalist taxa labels Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request inat 🍃 iNaturalist cog taxon iNaturalist taxa
Projects
None yet
Development

No branches or pull requests

1 participant