feat(search): spatial coverage facet + exclude world from lower-level filters#1039
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Same two
/searchchanges as #1038 (merged tostaging), targeted atmain.spatial_coveragesto the aggregations.get_facets()now requests thespatial_coveragefacet and translates slugs viaArea(name_{locale}), mirroring the existingorganizationsfacet. Output shape matches the other facets:[{key, count, name, fallback}].worldfrom lower-level spatial filters. Selecting a specific area OR'd inspatial_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); onlyworldis dropped.Backs the website spatial-coverage filter (basedosdados/website#1594).
Test plan
Verified against a local stack (Elasticsearch + fixtures,
rebuild_index):/searchaggregations includespatial_coverageswith correct localized names/counts.?spatial_coverage=br→ 294 (was 673);world→ 379;us→ 175 (no world leak);br_sp→ 306 (São Paulo + country rollup, no world).Not included here
The
worldArea rename to "International"/"Internacional" is a data change (updates theArearow's names; slug staysworld). 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