"term_id_or_unknown" query parameter not working with "term_value_id"

Platform (Android, iOS, Website):
Website, API

Browser, if a website issue (Firefox, Chrome, etc) :
Chrome

URLs (aka web addresses) of any relevant observations or pages:
https://www.inaturalist.org/observations?place_id=122851&taxon_id=319974&term_id_or_unknown=12&term_value_id=13
https://www.inaturalist.org/observations?place_id=122851&taxon_id=319974&term_id=12&term_value_id=13

Description of problem
I can’t find many examples of proper usage, but it seems like the “term_id_or_unknown” query parameter is not working as intended. The examples below use web URLs, but the API appears to behave identically.

What I’m trying to do is a query for “all plant observations which are either flowering or have no plant phenology annotation”. But when I try this, it appears that the “term_id_or_unknown” parameter is treated the same as the “term_id” parameter:

https://www.inaturalist.org/observations?place_id=122851&taxon_id=319974&term_id_or_unknown=12&term_value_id=13 shows 58 observations
https://www.inaturalist.org/observations?place_id=122851&taxon_id=319974&term_id=12&term_value_id=13 shows 58 observations

break this up into two queries:

  1. without_term_id=12
  2. term_id=12&term_value_id=13

who knows exactly what’s intended except for the person who wrote the code?

when you use term_id_or_unknown + term_value_id, you will get only observations that have your term_id + term_value_id or observations with some other term_id.

when you use term_id_or_unknown + without_term_value_id, you will get observations with no term_id or any annotated observation without your term_id + term_value_id.

there’s some related discussion here: https://forum.inaturalist.org/t/identify-filter-without-annotation-not-working-properly/30148/18

1 Like

@pisum - thanks for your input, but it doesn’t address the concern I raised. Though the documentation is sparse, it seems like &term_id_or_unknown=12&term_value_id=13 should return all observations with either no Plant Phenology or with Plant Phenology = Flowering. I may be missing something, but it looks to me like it’s not working as documented, and this is a bug and/or incomplete/incorrect documentation.

I don’t think your suggested alternative would work even for people who wanted to do this in two queries. There appears to be another bug with the without_term_id parameter being ignored - e.g.,

https://www.inaturalist.org/observations?place_id=122851&taxon_id=319974&without_term_id=12 shows 223 observations, as does https://www.inaturalist.org/observations?place_id=122851&taxon_id=319974, and there are definitely some in the first group that have no annotation.

you mentioned the API earlier. you can go through that. for example: https://jumear.github.io/stirfry/iNatAPIv1_observations?per_page=200&place_id=122851&taxon_id=319974&without_term_id=12&verifiable=true.

the only explanation i see is:

Must have an annotation using this controlled term ID and associated term value IDs or be missing this annotation

does that mean what you suggest? if i read it literally, it seems to suggest that it would get plant phenology = flowering or not ( plant phenology = flowering ) – which means what exactly?

on the other hand, if i take “term_id_or_unknown” literally, that would suggest an observation where term_id = 12 or where not exists (any term id), which isn’t quite what you suggested either.

like i said before, who knows what is intended except for the developer?