Landscape-Data-Commons / trex

Terrestrial Rangeland data EXtraction
Creative Commons Zero v1.0 Universal
2 stars 0 forks source link

Implement non-exact matching for fetch_ldc() #3

Closed nstauffer closed 1 year ago

nstauffer commented 1 year ago

There's now the option to append "Like" to the end of a variable name to retrieve records that contain the value but do not necessarily exactly match it. This may only work with string variables, so it'll take some testing to make sure it's all good. Basically, just add exact_match as a logical argument defaulting to TRUE because that's the expected behavior.

nstauffer commented 1 year ago

Turns out that if you use "Like" you can only pass one key value in the query. So the question becomes if the function should support more than one key value at a time by doing a query per value when using "Like". This could get messy since it could be a flood of queries to the API if there are a bunch of keys, e.g. exact_match = TRUE with ten key values would be ten rapid-fire queries and then if using a small take value like 100 it could easily balloon into dozens or hundreds of queries.

I'm inclined to have it only use the first key value and warn the user that that's what's happening, making them do their own legwork to do multiple function calls if they want to search by multiple key values with exact_match = FALSE. The alternative is to generate queries for each provided key value and potentially add some throttling to slow down the queries to avoid swamping the API or getting queries rejected for coming to quickly.

Thoughts or opinions, @smccord or @josephbrehm?