-
Notifications
You must be signed in to change notification settings - Fork 39
new endpoint observations/places_counts #511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
new endpoint observations/places_counts #511
Conversation
| "name": "United States", | ||
| "slug": "united-states", | ||
| "display_name_autocomplete": "United States", | ||
| "display_name": "United States", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I used "CorePlace" as a place object for my response, I need to add this to the test for working. I'm open to suggestions about this, maybe I should use another object
| by_place: { | ||
| terms: { | ||
| field: "place_ids", | ||
| size: 1000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have enough context to define the appropriate size for a search like this — 1000 seems like a reasonable limit to me, but my reasoning isn't very strong here. I'm open to suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- let's go with
observations/place_counts, notobservations/places_counts - this still needs a param that allows the user to specify which places are being bucketed, so something like
count_place_id
|
I chose the plural places by imitating As for the count_place_id param, maybe I’m misunderstanding something, but since I’m using the same parameters as In this new endpoint, results are ALWAYS bucketed by place. You can choose to limit which places appear in the output or not, and that's controlled via the |
kueda
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose the plural places by imitating /observations/species_counts. I think it's better to aim for consistency as much as possible, but I'm fine with changing it.
One the many weird and annoying things about English is that "species" is both the singular and plural form, e.g. "1 species, 2 species, 3 species."
As for the count_place_id param, maybe I’m misunderstanding something, but since I’m using the same parameters as /observations, I can already filter by place_id to specify which places I want to query. What would be the difference between that and a separate count_place_id?
I think one of us is misunderstanding, so maybe @loarie can clarify. My understanding of the request is to enable a chloropleth map, so given the observation query parameters, show the number of matching observations in an arbitrary collection of places, e.g. "show me the number of plants observations in France and Spain and don't show me counts for any other places". You can't achieve that with what you've got here and place_id=france,spain b/c you get a lot of irrelevant places.
|
I believe the issue is that there is not an additional filter on the aggregation itself in elastic search, hence why kueda is saying you will get a lot of irrelevant places returned in the results. Each observation has an array of place id’s, and from what I can see, it can span different granularities (For example, Europe > Spain > Andalucía > Cádiz). This observation, for example, has 16 place id’s returned with this observation via the API, including some beyond the 4 I described (community curated ones like the Mediterranean — you can look at the full list by clicking under the map, on “Details”). If I call the observation API with just one of its 16 place id’s, this observation will be returned with its list of 16 place id’s. If I’m reading this pull request correctly, the logic will not just return the counts for the requested So, it seems to me that there are two ways forward with the pull request: I think the official iNat team can chime in about why it’s important to distinguish between If this pull request is stale / you’d like to move on, I’d be happy to continue your work and pull your branch into my fork @jotamayo97 |
|
Thanks for the explanation @kfc35 . |
closes #56
The way I see it, since this endpoint is meant to accept all the same parameters as /observations, it’s essentially just an observation search grouped by places.
Instead of returning individual observations, it returns a list of places along with the count of observations that match the given filters .If place_ids are specified, only observations from those places will be considered, so only those places will appear in the results. However, it's still possible to filter by any other parameter.

Places with zero observations are not included.
I've only implemented it in v1 for now. I haven't fully understood the purpose and current state of v2 yet, but I can implement it there as well if you prefer.