Skip to content

Add intelligent CKAN instance detection to ckan_smart_search orchestrator #18

Description

@KlementMultiverse

Context

Issue #17 proposes a ckan_smart_search orchestrator tool that accepts natural language queries like "find climate datasets in Italy." This would dramatically improve accessibility for non-technical users who don't know which CKAN portal to query or its native search syntax.

However, the current implementation approach assumes users either:

  1. Already know which CKAN instance they want to query (and pass a URL)
  2. Manually specify the country/region before searching

This creates friction for the primary use case: "I'm looking for data about X, in country Y" — without requiring users to know that Italy's data portal is dati.gov.it, Canada's is open.canada.ca, etc.

Problem

Today, a user asking "find renewable energy statistics for Denmark" would need to:

  • Know that Denmark uses an open data portal
  • Know its URL is the correct CKAN instance
  • Or provide it manually before the search runs

This defeats the purpose of a natural language interface. The orchestrator should be smart enough to route queries to the right CKAN instance based on geographic and contextual clues.

Proposed Solution

Add an optional CKAN instance detector to ckan_smart_search that:

  1. Parses geographic references from the query ("Denmark", "Italy", "Canada") using existing tools or a lightweight regex/NLP approach
  2. Maps countries to known CKAN instances using a configuration file (e.g., src/config/ckan-instances.json) with entries like:
    {
      "IT": {"url": "https://dati.gov.it", "names": ["italy", "italia"]},
      "CA": {"url": "https://open.canada.ca", "names": ["canada"]},
      "US": {"url": "https://catalog.data.gov", "names": ["usa", "united states"]}
    }
  3. Defaults to user-provided instance if geography is ambiguous or not detected
  4. Logs the detected instance in responses so users understand where the search ran

Why This Matters

Without detection, ckan_smart_search is still more convenient than raw API calls, but it doesn't feel "smart" — it still requires domain knowledge (knowing which portal to use). With detection, it becomes a true natural language interface that non-technical users can trust.

Good Example

User: "Where can I find water quality data in France?"

Server (internal):

  • Detects "France" → maps to https://www.data.gouv.fr
  • Runs search: package_search(q='water quality')
  • Response: "Found 47 datasets on data.gouv.fr about water quality..."

User doesn't need to know about data.gouv.fr; the orchestrator figured it out.

Success Criteria

  • ckan-instances.json added with 10+ major CKAN portals (data.gov, dati.gov.it, open.canada.ca, etc.)
  • Detector integrated into ckan_smart_search workflow
  • Graceful fallback if geography can't be parsed
  • Updated docs/guide/ with examples showing geographic queries

Contributed by Klement Gunndu

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions