Filter by multiple annotations at a time

Platform(s), such as mobile, website, API, other: Website, mobile

URLs (aka web addresses) of any pages, if relevant: Identify module

Description of need:
Improve filtering for different annotations

Feature request details:
Add functionality to search for or url filter multiple annotations. This would be beneficial both for multiple annotations and different annotation values, preferably all at the same time. Currently there is very limited ability to search for observations with more than one annotation filter. As far as I can tell, the only use case that actually works is something like this, searching for observations with one value and without another, but they must be the same annotation: https://www.inaturalist.org/observations/identify?term_id=22&without_term_value_id=24&term_value_id=23

Some cases I’ve run into that I wasn’t able to accomplish was something like searching for observations without a life stage while filtering out those without evidence of presence set to something specific (like leafmine or egg). I also couldn’t find a way to search for observations with multiple evidence of presence annotations (like organism and molt).

I’ve found multiple related topics on the subject (2 other more specific feature requests that may benefit from this broader one, and a bug report about the functionality of excluding certain annotations):
https://forum.inaturalist.org/t/exclude-specific-annotations-from-a-project-e-g-observations-annotated-as-dead-animals-scat-or-tracks/36547
https://forum.inaturalist.org/t/collection-project-using-without-annotation-filter/28212
https://forum.inaturalist.org/t/identify-filter-without-annotation-not-working-properly/30148

Perhaps others can chime on other similar workflows that would benefit from this functionality.

Clarification:
Add the ability to search for annotations by term_value_id and without_term_value_id without requiring term_id. The term_id numbers are unique compared to the term_value_id numbers, so an “any” search could still work. Ideally these searches could be done with AND or OR, so you could search for observations with organism OR molt and then search for observations with organism AND molt. Something like term_value_id=24,28 vs term_value_id=24+28.

this functionality does exist, but search filters must be manually added to the URL rather than through a user interface. this is the list of them.

i have created an Identify search with your described filtering needs:

  • without life stage annotation: without_term_id=1
  • with evidence of presence annotation: with_term_id=22
  • particularly, with “organism” and “molt” evidence of presence annotations: term_value_id=24,28
  • presuming from search terms that you are interested specifically in phylum Arthropoda

plain URL with all filters added:

  • https://www.inaturalist.org/observations/identify?quality_grade=needs_id%2Cresearch&without_term_id=1&term_id=22&term_value_id=24%2C28&taxon_id=47120

i agree these advanced search filtering methods should be made more accessible to users. i hope these resources can help you for now.

2 Likes

This doesn’t really work.

For the first part, it doesn’t allow for specific values to be excluded, only the whole annotation or term ID. I want to find observations with no life stage and without a specific EoP annotation (namely leafmine or egg), not without any EoP annotation.

And for the second part, I am specifically looking for observations with both EoP annotations, organism AND molt. This url finds observations with one or the other (and presumably both, but there’s no way to pick them out of the list)

please refer to the linked guide and the search filter provided (I can see you did not even click them) before telling me it does not work, as you absolutely can include/exclude specific values to your discretion. you can include/exclude annotation groups AND/OR specific annotations within group.

but yes, it seems an AND function is not really included in the search, it defaulted to OR. this is needed.

1 Like

Sorry, I didn’t mean it didn’t work functionally. I meant it didn’t work for my use case.

I’m looking for without life stage and without a specific EoP annotation. Your link is without life stage and WITH EoP = 24,28

i misunderstood your description of your need,

i was trying to give you this search for multiple possible evidence of presences, and found that you cannot do AND: tried to separate the search terms and that didn’t work either.

the other search is also possible: arthropod observations (1) without any life stage annotation, (2) with EoP annotation (3) BUT EoP annotation NOT organism or molt.

https://www.inaturalist.org/observations/identify?quality_grade=needs_id%2Cresearch&without_term_id=1&term_id=22&without_term_value_id=24%2C28&taxon_id=47120

let me know if this addresses your needs or if i have misunderstood.

This was very helpful for other use cases though. The UI is limiting, so I didn’t realize I’d be able to successfully create filters that granular with the URL.

I still think the other functionalities would be very helpful. I can try to summarize my ask better in the original post

This one is helpful too. But still a bit limited (hopefully I’m not asking for too much).

I guess for condition 3, I was searching for either no EoP annotation or any EoP annotation besides the ones you listed.

I’ll try to describe a specific use case, maybe that will help clarify better than my words can.

I’m looking to annotate Lepidoptera observations for life stage (adult, larva, pupa, etc), but I want to exclude only observations that have been annotated with EoP=leafmine. Any other EoP annotation I want included in the search

no worries, i am very glad to help with search filtering (i think i am surprising myself with how passionate i am about it, in terms of being able to sort the huge amount (200 million +) observations! it is so important)

thank you for your very specific use case, as this helps solve things: you don’t need to include the term_id=22 at all. simply leave it out and your search WILL include those which have no annotation. it only eliminates the EoP annotations which do not interest you. this is the search filter i have designed for it:
https://www.inaturalist.org/observations/identify?without_term_id=1&without_term_value_id=32&taxon_id=47157

I certainly appreciate your help. I definitely learned a few things. I’ll clarify the ask in the original post once I clarify things in my own head lol

I was playing with your last link to get the results I was looking for. I used this search:

https://www.inaturalist.org/observations/identify?without_term_id=1&taxon_id=47157&project_id=33779&place_id=any&without_term_value_id=32

I included the project id since that project is for leafmines and I could easily tell if the search was working. But I’m finding lots of observations in there with the leafmine annotation, despite having the &without_term_value_id=32 in the url. Did I not follow correctly?

i am experiencing the same in spite of the without_term_value_id=32, so i must have done something wrong. it looks like the guide says “Both the group parameter and value parameter should be included in the URL,” so perhaps it is not possible to include both groups (observations with an annotation that is NOT a specified value, observations without that annotation altogether)? i defer to whoever made the search filters.

That appears to be the crux of the issue. You can’t have multiple with_term_id or without_term_id in the same url, otherwise the term_value_id part wouldn’t know which term_id to look at.

1 Like

in light of that, maybe the more accurate feature request is for a way to indicate a sort of NULL within the search (which i do not know if it exists), so you can call term_value_id or without_term_value_id to include/exclude those in the search.

i will be back to check on this thread later, i need to take an exam!

2 Likes

I added this clarification to my original post which I think covers what my ask is. I think that would cover all situations for filtering annotations, or at least all the ones I’m looking for.

Clarification:
Add the ability to search for annotations by term_value_id and without_term_value_id without requiring term_id . The term_id numbers are unique compared to the term_value_id numbers, so an “any” search could still work. Ideally these searches could be done with AND or OR, so you could search for observations with organism OR molt and then search for observations with organism AND molt. Something like term_value_id=24,28 vs term_value_id=24+28.

Agreed. I would often quite like to do &without_term_id=1,9 - i.e. with neither life stage nor sex annotation

1 Like

I created some basic Evidence of Presence collection projects. With the different project filters combined with annotation filters, I can basically accomplish everything I need to now. It would still be nice to have this supported functionality, but having these projects is a suitable workaround for me

https://www.inaturalist.org/projects/evidence-of-presence-bone
https://www.inaturalist.org/projects/evidence-of-presence-construction
https://www.inaturalist.org/projects/evidence-of-presence-egg
https://www.inaturalist.org/projects/evidence-of-presence-feather
https://www.inaturalist.org/projects/evidence-of-presence-gall
https://www.inaturalist.org/projects/evidence-of-presence-hair
https://www.inaturalist.org/projects/evidence-of-presence-leafmine
https://www.inaturalist.org/projects/evidence-of-presence-molt
https://www.inaturalist.org/projects/evidence-of-presence-organism
https://www.inaturalist.org/projects/evidence-of-presence-scat
https://www.inaturalist.org/projects/evidence-of-presence-track

This url now fits my need of Leps with no life stage and without a leafmine annotation: https://www.inaturalist.org/observations/identify?taxon_id=47157&without_term_id=1&place_id=any&not_in_project=evidence-of-presence-leafmine

Hopefully these projects will be useful to some people

5 Likes

I ended up taking it a step further and made one for every annotation, plus an umbrella project here: https://www.inaturalist.org/projects/annotation-projects

I plan on making a journal post in that project (or perhaps I should do a tutorial forum post?) on how these projects can be used to enhance annotation-related search queries.

1 Like

This is a smart idea for a workaround. Is there a reason why you aren’t including Casual observations in the project? Most people don’t interact with them much, but it seems possible that someone might want to do an annotation search on, say, cultivated plants.

1 Like

I may have forgotten to include them on a couple. I can check the settings. But I my intention was to include all observations, including casual

I double checked. All the projects include casual observations too. I hope people can make good use of these!

1 Like