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:
and:
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:
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.
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:and:
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 passwith_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:
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 thetaxon_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 withwith_term=True
, instead of looking it up again bytaxon_id
.