Skip to content

feat(search): spatial coverage facet + exclude world from lower-level filters#1039

Merged
rdahis merged 2 commits into
mainfrom
claude/spatial-coverage-facet-main
Jul 9, 2026
Merged

feat(search): spatial coverage facet + exclude world from lower-level filters#1039
rdahis merged 2 commits into
mainfrom
claude/spatial-coverage-facet-main

Conversation

@rdahis

@rdahis rdahis commented Jul 9, 2026

Copy link
Copy Markdown
Member

Summary

Same two /search changes as #1038 (merged to staging), targeted at main.

  1. Add spatial_coverages to the aggregations. get_facets() now requests the spatial_coverage facet and translates slugs via Area (name_{locale}), mirroring the existing organizations facet. Output shape matches the other facets: [{key, count, name, fallback}].
  2. Exclude world from lower-level spatial filters. Selecting a specific area OR'd in spatial_coverage_exact:"world", so filtering by Brazil returned Brazil-only datasets plus every global dataset (294 → 673). Global datasets are indexed as ["world"] only (get_spatial_coverage), so the facet counts were already exclusive; this aligns the filter results with them. Ancestor rollup is preserved (a state still matches its country); only world is dropped.

Backs the website spatial-coverage filter (basedosdados/website#1594).

Test plan

Verified against a local stack (Elasticsearch + fixtures, rebuild_index):

  • /search aggregations include spatial_coverages with correct localized names/counts.
  • ?spatial_coverage=br294 (was 673); world → 379; us → 175 (no world leak); br_sp → 306 (São Paulo + country rollup, no world).

Not included here

The world Area rename to "International"/"Internacional" is a data change (updates the Area row's names; slug stays world). It resolves at query time (no reindex) — apply it on the target DB or as a data migration, not via this code PR.

🤖 Generated with Claude Code

rdahis and others added 2 commits July 9, 2026 23:30
Mirror the organizations facet in get_facets() so /search/ returns a
spatial_coverages bucket list ({key,count,name,fallback}); the website
search filter seeds its choices from this aggregation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Selecting a specific area (e.g. br) OR'd in spatial_coverage_exact:"world",
so filtering by Brazil returned Brazil-only datasets plus every global
("world") dataset (294 -> 673). Global datasets are indexed as ["world"]
only (get_spatial_coverage), so the facet counts were already exclusive;
this aligns the filter results with them. Ancestor rollup is preserved
(a state still matches its country); only world is dropped.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rdahis rdahis self-assigned this Jul 9, 2026
@rdahis rdahis merged commit ba2501b into main Jul 9, 2026
5 checks passed
Winzen added a commit that referenced this pull request Jul 10, 2026
Sincronização da branch staging com main, trazendo os PRs mergeados desde o último sync.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant