When spatial search in CKAN earns its place on a data portal
Spatial search in CKAN lets users find datasets by the area they care about, drawn on a map or entered as coordinates, and it works alongside the title and tag search they already use. It is worth enabling when a portal holds a meaningful number of datasets with geographic extents, such as planning layers, transport networks, environmental monitoring or census geographies, and when a significant share of users think in places: a neighborhood, a river catchment, a municipal boundary. Map-driven users, including GIS staff who expect to start from a map, are the clearest case. The feature depends on each dataset carrying a spatial extent that the search index can use, so the first decision is whether your catalog's metadata can support it.
A plain keyword and facet search is enough for many portals. If the catalog is small, most datasets are not geographic, or users search by topic, publisher, format or license, a well-maintained set of tags, groups and facets will serve them without adding any spatial configuration to run. Spatial search is also of limited value when extents are missing or too coarse. Datasets without an extent should be expected not to appear in map-based results, so a search that looks complete may quietly omit records. Before enabling it, count how many datasets carry a geographic extent, review a sample of those values, and decide what happens to the rest. Ask your catalog owners how extents are entered today, because the search will only be as reliable as that input.
The decision is as much about operations as about the feature itself. Spatial search runs on the Solr index that CKAN maintains, so the team needs to confirm that its Solr version fits the CKAN release it plans to run, and that someone owns reindexing after bulk imports or harvests. Plan a trial against a copy of the catalog. Check that the map returns datasets you know should match, that edge cases such as datasets covering a whole country or a single point behave as your users expect, and that the results still make sense when keyword and facet filters are combined with the map. Confirm the exact settings and supported versions against the documentation for your CKAN release before committing to a timeline.
Spatial search options in CKAN and when each fits
This table compares the main choices for getting dataset extents into CKAN, exposing spatial search, choosing a Solr version and keeping extents in PostGIS. Read each row for its trade-off, the situations where it fits and the team that owns the decision. The main takeaway is that the extent source and the Solr version shape most of the work, so settle them before you build the map widget.
| Choice | Trade-off | When it fits | Owned by |
|---|---|---|---|
| Manual spatial fields | Curators type extents by hand, so accuracy depends on each entry and nothing is reused. | Small catalogs with few datasets and no existing geospatial metadata. | Data curators |
| Harvested ISO 19139 metadata | Extents are inherited from source records, so errors in the publisher's metadata carry over. | Organizations that already publish geoportal or metadata catalog records. | GIS staff set mappings, platform engineers schedule harvests |
| Imports from other catalogs | Extents arrive only if the source publishes them in a form the RDF import maps. Check first. | Portals that need datasets from another DCAT-based catalog. | Data curators review imports, platform engineers run them |
| Map widget for end users | Users draw a bounding box in the browser, but map and theme changes need front-end testing. | Public portals where residents or researchers search by place. | Platform engineers with front-end developers |
| API as the only entry point | Users never see a map, so spatial search depends on API queries or integrations. | Machine consumers, GIS clients or scripted reuse without a public map. | Platform engineers |
| Solr 9 (recommended) | Recommended in the CKAN install docs. Confirm it works with your CKAN release and extensions. | New builds, unless a compatibility check says otherwise. | Platform engineers |
| Solr 8 (supported) | Supported per the CKAN install docs, but Solr 9 is the recommended option. | Existing Solr 8 estates that cannot move yet. | Platform engineers |
| Extents kept in PostGIS | Enables spatial SQL and GIS editing, but adds a second database to keep in step with CKAN. | Teams doing spatial analysis or editing geometry outside CKAN. | GIS staff, with platform engineers operating the database |
How spatial search in CKAN indexes dataset extents in Solr
Box search works only if each dataset carries a usable extent before it reaches the index, so that is the first thing to check. When a dataset is saved, ckanext-spatial reads its geometry from the dataset's spatial metadata, usually a GeoJSON geometry held in a dataset extra, and writes it into the Solr index next to the text and facet fields CKAN already indexes. Solr then stores the extent as a spatial field that can be compared with a query shape. Confirm in the ckanext-spatial README for your version which extra holds the geometry, how invalid geometries are handled on save, and whether datasets without one are indexed at all. Datasets missing a valid extent will never match a box, so audit them before launch.
At query time, the map widget or an API caller supplies a bounding box, and the extension turns it into a spatial filter that Solr evaluates against the stored extents. Matching datasets are those whose extent intersects the box, or those that fall within it, depending on the query mode the extension exposes for your version. The modes give different results for large extents. Illustrative example: a national dataset that covers a city's box will match an intersects query and fail a within query. Confirm the box parameter name (the API parameter is often documented as ext_bbox), the coordinate order, the coordinate reference system and the mode parameter against the README. Run one known dataset through each mode before you publish.
Solr version and index maintenance decide whether results stay reliable after launch. The CKAN installing from source guide recommends Solr 9 and still lists Solr 8 as supported, so confirm which version your CKAN release targets. Confirm also that the schema match holds: the schema shipped with your Solr and CKAN versions must include the spatial field type ckanext-spatial expects. A mismatch can make box queries return nothing or fail without an obvious error. Plan a search index rebuild after changes to the spatial configuration, the extension or Solr, and confirm the rebuild procedure in the CKAN operations documentation for your version. After each upgrade, repeat the known-dataset test and record the expected result for each dataset so someone else can repeat it.
Setting up spatial search in CKAN step by step
This sequence takes a CKAN instance from a working base install to one where users can find datasets by drawing a bounding box. Each step ends with a check you can run, so a fault is caught at the step that introduced it. The result is a tested setup that finds datasets by extent, which the map widget and API features build on.
Confirm the base CKAN prerequisites
Before installing anything, confirm that the host runs Python 3.10 or newer and that PostgreSQL 12 or newer, Solr 9 (recommended) or Solr 8, and Redis are available to the CKAN instance. The CKAN install from source documentation lists these prerequisites, and your team or the implementation partner records the versions in your environment. The check is that
python3 --versionreports 3.10 or newer,psqlconnects to the CKAN database, the Solr core answers a status request, andredis-cli pingreturns PONG. Write down the Solr core name and URL now, because later steps depend on them.Install ckanext-spatial for your CKAN version
Install ckanext-spatial from the branch or release that matches your CKAN minor version, into the same virtual environment that runs CKAN. Install the Python dependencies and any system libraries that its README lists, since geospatial packages often need them. A version mismatch is a frequent cause of plugin load failures, so check the compatibility note before running pip. The check is that
pip show ckanext-spatialreports the package in the CKAN environment and that the CKAN start-up log shows no import errors. The output is a CKAN instance that starts with the extension installed but not yet enabled.Enable the spatial plugins in the CKAN configuration
Add the ckanext-spatial plugins to
ckan.pluginsin the production config file, keep the existing plugins, and set the search backend key that the extension documentation names for Solr. Confirm each plugin name and everyckanext.spatial.*key in the README for your installed version before you save the file. Restart the CKAN web processes and confirm that the instance starts cleanly and the dataset pages load. The output is a CKAN instance with the spatial plugins active, visible in the running configuration with no errors on the dataset pages.Add the spatial field to the Solr schema
Copy the spatial field definition and any field type that ckanext-spatial documents into the managed schema of the Solr core that CKAN uses, then restart Solr so the schema loads. This step makes dataset extents searchable, and a missing field tends to appear later as search results that are quietly incomplete, with no error on screen. Open the Solr admin interface for the core, confirm the spatial field appears in the field list, and confirm that Solr restarts without errors. The output is a Solr core that accepts the spatial field.
Rebuild the search index
Run the CKAN search index rebuild on the CKAN host with the production configuration, using
ckan -c /path/to/production.ini search-index rebuild, so existing datasets are indexed again with their spatial extents. Datasets indexed before the schema change have no extent in Solr until this runs. Rebuild time grows with the number of datasets, so test the command on a copy of the portal first and run it outside busy hours. Check the result by querying Solr for one dataset you know has an extent and confirming that its spatial field holds a value. The output is an index where known datasets carry their extents.Run a bounding box query against a known dataset
Pick two datasets with known extents, then call the package search API with the bounding box parameter that ckanext-spatial documents, using coordinates in the order its README specifies. Illustrative: a dataset whose extent covers a city should appear in a box drawn around that city and should not appear in a box over an unrelated region. Confirm the parameter name and coordinate order in the extension documentation before you write tests against them. Record both results and rerun the same queries after each future index rebuild. The output is a repeatable test that shows the index and the query agree.
How a bounding box query reaches Solr and returns to the results page
The diagram has two paths. A dataset that is saved or harvested has its extent validated in CKAN before a Solr document is written, and the record itself is stored in PostgreSQL. A bounding box drawn in the map widget, or sent to the API, follows the query path: CKAN validates the coordinates, builds the Solr spatial filter, and receives matching dataset IDs from Solr before it renders the results page. The subgraph marks the trust boundary between the public web tier and the Solr and PostgreSQL services, so requests leave the web application at the spatial filter. Check that validation rejects malformed or inverted coordinates before any query reaches the search service, and that extent validation runs before indexing.
Indexing and query paths, with validation points inside the public web tier.
Why bad extents make spatial search results unreliable
Spatial search is only as accurate as the extent stored for each dataset. A dataset with no extent, a box with latitude and longitude swapped, a box in the wrong coordinate reference system, coordinates in the wrong order, or a box that covers half a country will all still return results when a user draws a box on the map. The results look plausible, so nobody notices until a user reports that a local dataset never appears or that a national dataset appears in every search. The failure is silent. Extents reach CKAN through the dataset form, through harvested ISO 19139 records, or through the API, and each route can introduce a different error. The fix has to cover all three routes.
Put three checks in place before the portal relies on spatial results. First, make the extent a required field on publish, so a dataset cannot become public without one. Confirm whether ckanext-spatial's form and validators enforce this in your version or whether a custom schema plugin is needed. Second, validate coordinate ranges on every write: longitude from -180 to 180, latitude from -90 to 90, and the minimum below the maximum on each axis. Range checks catch many swaps but not all, because a swapped pair can still fall inside valid bounds. Third, sample datasets each release cycle and compare the stored box with the bounds on the source map. The sample catches what the validators cannot, including overly large boxes that pass every range rule.
Assign ownership before the first harvest rather than after the first complaint. Dataset publishers own the extent on each record, because only they know the area a dataset covers. The portal team owns the publish rule, the coordinate validators and the sample check, and whoever runs the harvests owns mapping errors that come from source records. Before you rely on any of this, confirm how ckanext-spatial handles a dataset with no extent in your version: whether it is indexed without geometry and silently left out of bounding box results, or whether the harvester rejects it. Also confirm which coordinate reference system the extension expects, and whether records in another system are reprojected or refused. Reindex after correcting extents, or the Solr index will keep returning the old answers.
Security and operating risks of spatial search in CKAN
Spatial search adds a bounding box to the same Solr queries that serve every CKAN search, so these risks sit where the index, the user input and the permission model meet. Each card names what to check and whether the fix is configuration, code or process.
Solr exposed to the public network
Solr holds the spatial index and serves its query and administrative interfaces on its own port. Keep Solr on a private network segment that only the CKAN web and worker hosts can reach, with no route from the internet. Check firewall rules, confirm that the Solr admin interface is disabled or requires authentication, and scan the host from outside your network. Match the Solr version to the one your CKAN release supports, since the install guide names a recommended version. Fix type: configuration.
- Recommended version
- Solr 9
Validate bounding box input
The spatial parameters accept coordinates from the browser and from API callers. Reject malformed coordinates before they reach Solr: values outside longitude and latitude ranges, boxes where the minimum exceeds the maximum, non-numeric text and geometries too large to process in one request. Build the spatial filter from parsed numbers, never from raw parameter text. Test with empty, malformed and extreme values, and confirm that errors return a clear message instead of a server trace. Fix type: code.
Private datasets in spatial results
A spatial query is a separate filter added to the Solr request, and it must carry the same visibility filter as text search. If the spatial path omits the permission filter, private dataset titles and extents appear to users who should not see them. Run a spatial search as an anonymous user and as a member of another organization, then compare the results with the same query in text search. Repeat the test after every upgrade and after any change to search customizations. Fix type: code or configuration.
Reindex after schema changes
Changing the Solr schema, the spatial field mapping or an extension that writes to the index changes what is stored for each dataset. Existing datasets keep their old index entries until they are reindexed. Plan a full index rebuild for every schema or extension change, and schedule it for a window where briefly stale results are acceptable. Compare document counts before and after the rebuild, then run a spatial search on a dataset whose extent you know. Check the release notes for your CKAN version before upgrading. Fix type: process.
CKAN release notesBack up the index with the database
PostgreSQL holds the dataset records that Solr is built from, so a rebuild can recover the index. A rebuild on a large catalog, however, takes time that a restore does not. Back up the Solr data and its configuration directory on the same schedule as the PostgreSQL dump. Test a restore of both, and time it, including the rebuild path if you choose not to restore the index. Confirm that the backup set includes the Solr schema that matches your extensions. Fix type: process, owned by the operations team.
Logging search queries for review
Query logs show which places users search for, and bounding box coordinates can reveal interest in a specific site or address. Decide what is logged before logging is turned on, including whether coordinates are kept at full precision, how long logs are retained and who can read them. Check that logs do not capture API tokens, session cookies or names of private datasets in query strings. Agree these settings with your privacy and security leads. Fix type: process, applied through your log pipeline configuration.
What spatial search in CKAN costs and what it asks of your team
What drives the cost of spatial search in CKAN?
Cost follows how much spatial metadata has to be created, cleaned or checked before search results can be trusted. Five components usually carry it:
- Metadata cleanup: how many datasets have missing, approximate or inconsistent extents, and how far the review reaches into titles and keywords.
- Number of datasets with extents: every dataset that needs a reviewed bounding box adds review and testing time.
- Extent sources: geometry may come from harvested ISO 19139 records, from a manual extent in the dataset form, or from resource files, and each source needs its own mapping and validation.
- Map widget customization: the drawing tool, base map, styling and translations the search page needs.
- Solr and hosting work: the Solr version, index settings, server changes, reindexing and testing of results in the interface and the API.
Which costs are one-time and which recur after launch?
Setup and cleanup are one-time, while upgrades, reindexing and checks recur. The one-time part covers the initial ckanext-spatial configuration, extent cleanup across existing datasets, the map widget build and the first full reindex with search tests. The recurring part covers CKAN upgrades, since minor releases can include backwards-incompatible changes and patch releases carry fixes for the supported versions. It also covers reindexing after extent mapping or schema changes, and periodic checks that new datasets carry valid extents. Ask the quote to show these as separate lines so you can see the ongoing load before you sign.
Can our internal team set up spatial search without a partner?
Yes, if your team already runs CKAN and Solr well and has someone comfortable with GIS concepts such as extents, coordinate reference systems and bounding boxes. The main gap is usually metadata quality, and software skills are rarely the constraint. Existing datasets often have missing, approximate or inconsistent spatial fields, and cleaning them requires people who know the data and the publishing organizations. Check three things before deciding: whether someone on the team has handled a Solr upgrade before, whether there is time for a full test pass across search results and the API, and whether your front-end developers can own widget changes. A partner mainly adds value when the cleanup is large or the schedule is tight.
How long does spatial search in CKAN take to deliver?
The schedule depends on the same factors as cost, and no fixed duration applies across all portals. The biggest variables are how many datasets need extents, how much metadata must be reviewed by data owners outside the project, which extent sources must be built and validated, and how many environments need testing before release. Lead times for infrastructure requests, such as a staging Solr server or a change window for reindexing a production index, can set the calendar more than the build itself. Ask for a schedule that lists each dependency and the person who owns it, and treat any single figure without that breakdown as incomplete.
What should a written quote for spatial search include?
A useful quote lists what is in scope, what is excluded and who does each task. Ask for:
- The dataset count and the metadata sample the estimate is based on, with the cleanup rules applied.
- Each extent source and the validation it receives.
- The map widget scope, including base map, drawing tool, translations and browsers covered.
- Solr, hosting and reindexing work, with the environments involved.
- Testing of search results and API responses, with agreed acceptance criteria.
- Recurring upgrade and support terms after go-live, plus what you must provide, such as data owner time and system access.
DeployOpen does not publish a price list, and a quote follows from the written scope. Fixed-scope engagements are agreed in writing before work starts, so confirm deliverables, timeline and the change process in the same document.
What breaks most often in spatial search after go-live?
Most failures trace back to extents that are wrong, missing or in an unexpected coordinate system, so search looks correct for some datasets and empty for others. Other common issues are a search index that was not rebuilt after extent mapping changed, harvested records that overwrite manual fixes on the next run, and map widget changes that work in one browser but fail in another. Before launch, compare a sample of datasets against their source records, run bounding box queries at small, large and wide extents, and confirm the index is rebuilt after each harvest or schema change. Keep those checks on a recurring list so they run after every upgrade and harvest.
Who maintains spatial search once the project closes?
Your team owns it after handover, and the handover is where most ongoing decisions are made. Document where extents come from, which harvest sources feed them, how the index is rebuilt and who approves changes to the map widget. Plan around CKAN's release policy: the project supports the latest patch of the current minor version and the previous minor version, and outdated patch releases lose support once a newer patch is out. Minor releases can include backwards-incompatible changes, so upgrade testing has to be scheduled, not assumed. If you prefer an outside team to run upgrades, reindexing and continuous checks, a retainer can cover that, and its scope should be written like any other engagement.
Limits to confirm before promising spatial search to users
Spatial search depends on several components, and each has its own version rules and limits. The checks below cover the CKAN and Solr stack, the spatial metadata itself, and the hardware your catalog runs on, so confirm each one in your own environment before you describe what the map search will find and how fast it responds.
CKAN minor and Solr compatibility
ckanext-spatial targets specific CKAN minor versions, and its extension README is where it declares which ones. The CKAN install documentation recommends Solr 9 and also lists Solr 8, so confirm your Solr version against the target CKAN minor version as well. Minor releases may include backwards-incompatible changes, while patch releases do not break compatibility. Pin and test the CKAN and Solr pair before you commit to search behavior, and repeat the test before every minor upgrade.
CKAN release policySupported geometry types and coordinate systems
Spatial indexing only works for the geometry types and coordinate reference systems the extension accepts. Check the README for which geometry types it reads from harvested or uploaded metadata, and whether it expects a specific coordinate order and system. A dataset in a projected system, for example a national grid, may need reprojection before indexing, and a mismatch can place it in the wrong part of the map. Test one record of each geometry type from your own catalog and compare its position on the map with its known location.
Datasets without spatial extents
Many datasets have no bounding box, either because the source metadata omits one or because a manual entry was left blank. Confirm how ckanext-spatial indexes those records: whether they are excluded from spatial results, returned for every spatial query, or handled by a fallback. Decide what your portal should show for them and whether that matches what users expect from a map filter. Count the datasets without an extent before you describe the map search as complete, because those records may not appear when a user draws an area.
Result ordering and relevance
A spatial filter narrows the result set, but it does not settle how the remaining results are ranked. Confirm whether a bounding box query changes Solr relevance scoring, and whether your default sort order survives when a user draws an area on the map. Test with a query that matches several overlapping extents, including a dataset that only partly overlaps the box. Write down the sort order you promise users and verify it against the test catalog.
Performance on your catalog and hardware
Spatial queries add work to Solr and to the pages that display results, and the cost grows with the number of datasets and the complexity of their geometries. Ask the extension maintainers or your implementation partner for any documented load figures, then measure on a copy of your own catalog. Run typical and worst-case boxes, such as an area covering a whole country, during indexing and search at the same time. Size Solr memory and CPU from those results. Measure on a copy of your own catalog before promising response times.
Native geospatial library dependencies
Geometry handling in Python often relies on native libraries that the operating system must provide, and package versions differ between distributions. Check the extension README and its requirements for system packages, then confirm they install on your target operating system. The CKAN package install guide covers Ubuntu 20.04 and 22.04 64-bit, and source installs are documented to work on Red Hat, Fedora and CentOS. Build your staging image from the same package set you will run in production, so a library mismatch appears before launch.
CKAN install guideHow DeployOpen scopes and delivers spatial search in CKAN
DeployOpen plans and implements spatial search in CKAN inside your own infrastructure, so the bounding box search, the Solr index and the spatial metadata behind it stay under your control. We agree the scope in writing before work starts, then build against the CKAN version and Solr version your portal will run. The result is documented and handed over to your operators, with ongoing support available as a retainer.
How we scope
- Confirm which CKAN minor version and extension set the portal will run before fixing the effort.
- Written scope lists which datasets have extents, which spatial fields are indexed, and which API parameters are exposed.
- Scope states what the bounding box widget, Solr version and hosting environment cover, and what is excluded.
How we build
- Configure Solr 9 (recommended) or Solr 8 for CKAN, and check the spatial field setup the extension depends on.
- Validate extent values in harvested and manually entered datasets so bounding boxes index correctly.
- Test the map widget and API bounding box queries in a staging environment on your own infrastructure.
How we hand over
- Written documentation of the Solr configuration, index rebuild steps and extent validation rules.
- Test results showing expected datasets for each sample bounding box query, kept with the handover.
- Operator notes on search index maintenance and reindexing after schema or extent changes.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers for the spatial search stack.
- Upgrades to a newer CKAN minor version need a check of extension compatibility and the spatial index.
- CKAN patch releases exclude schema changes, but outdated patches lose support once a newer patch is out.

