Search by tags not present (not contain)

Hello,

Sorry if the question has already been asked (I’m a French speaker, and I may not be using the right search terms).

Is it possible to do a search based on tags, but which do “NOT CONTAIN” a particular term?

For example, I tag all my observations of moths with the tag “light trap” (link). I’d like to search for all my observations of Noctuidae that don’t have this tag.

Thank you for your help, if possible :smiley:

the system can return a filtered set of observations which have a particular tag. it does not provide a way to filter for observations which do not contain a particular tag on the server side, but you can get a list of observations and do your own filtering on the client side.

probably for most people in most cases, the easiest method for client-side filtering is described here: https://forum.inaturalist.org/t/search-self-observations-w-no-tag/39070/3.

if you know how to code, you can also do client-side filtering via the API in some cases. for example, i made a Jupyter Notebook (Python) which can retrieve observations and generate a CSV file. you could adapt that notebook to get your answer by making the following changes:

  • set req_params_string = 'taxon_id=48670&user_id=sylvainm_53'
  • in the # main execution section, use the following commands (lines 2 and 3 are optional):
    obs = await get_obs(req_params, get_all_pages=True, use_authorization=False, pre_parse_filter_function=(lambda x: 'light trap' not in [str(t).lower() for t in x['tags']]))
    obs_ids = [o.get('id') for o in obs]
    obs_id_sets = obs_ids_to_sets(obs_ids, prefix='https://www.inaturalist.org/observations?id=')
    

you’ll find that you have several observations that are tagged as “lignt trap” (misspelled) instead of “light trap” or are tagged as “piège lumineux” only.

2 Likes

Thank you Pisum :smiley:
I have some knowledge of coding, but I’m quickly limited.
I’ll try to explore Jupyter Notebook.
But it’s true that in the meantime, I can filter a more global export in an external application that I’m more familiar with :+1:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.