Advanced search with CKAN

The advanced search allows you to build structured queries using the CKAN Native Queries to search for metadata. You can specify criteria that you can't define in the quick or basic searches. For example, you can use the ORDER BY clause in when you’re searching for metadata.

In advanced search, you can use queries to find your issues. Queries are a series of elements or parts, like fields, operators, and values, that are strung together to form a structure.

In CKAN we use the [fq] parameter for all queries generated through the UI. For example if a user is searching for a string , they would need to set the field which they want to search on. Searching for a title of "water" would be a query like "title:water".

  • Toggle between Basic and CKAN query.
  • Query Editor
  • Apply search to get results.

Perform advanced searching

There are two ways to generate a CKAN query.

  1. Selecting filters on the filters view, automatically creates a CKAN query which is hidden behind the toggle button. By toggling the textbox you can see the generated query.
  2. Clicking on the toggle button opens the CKAN query editor. You can then write you own custom ckan query.

Constructing the CKAN Query Manually

The CKAN query is based on CKAN Query Native format. Documentation can be found here https://docs.ckan.org/en/2.9/api/#ckan.logic.action.get.package_search

There are two types of fields in our metadata schema, and these are plain fields for example [title], and extras which are field names with a prefix of extras for example extras_publisher_name. Below is a list of all available fields with and indication of extra or not.

The list below shows:

Ckan transformation fields

For LIKE string search use title:water, and for exact string match use title:("water").

For OR operator use brackets around your statement fir example (title:("historical") OR extras_alternativeTitles:("landfill"))

Metadata attribute (DSP)CKAN keyExtraDescriptionExampleTest Result
General
TitletitleNDataset Titletitle:water
Alternative TitlesalternativeTitlesYDataset Alternative titleextras_alternativeTitles:water
SummarynotesNDataset descriptionnotes:Water body measures are the actions
Organisationextras_publisher_nameYextras_publisher_name:("Animal & Plant Health Agency")
CategorycategoryYUser defined categoryextras_category:environment
Freetext KeywordstaxonomyKeywordsYextras_taxonomyKeywords:("water" OR "soil")
Workflow keywordsworkflowKeywordsYextras_workflowKeywords:("OpenData" OR "RetiredOpenData")
LicencelicenseYextras_license:("Open Government Licence")
Attribution statementlicence.attributionStatementYextras_licence:Environment Agency
Use limitation statementlicence.useLimitationStatementYextras_licence:Use Limitation Statement
Publishing bodypublisherYextras_publisher_name:("Environment Agency")
Creation datecreatedAtYextras_createdAt:18-02-2016
Publication datepublishedYextras_published:[12-01-2000]
Revision datemetadataModifiedYextras_metadataModified:[12-01-2000]
Draft statusdraftStatusYextras_draftStatus:Submitted
Published statuspublishedStatusYextras_publishStatus:Published
Contact information
- Individual namecontacts.individualNameYextras_contacts:Matt
- Organisation namecontacts.organisationNameYextras_contacts:Environment Agency
- Email addresscontacts.emailAddressYextras_contacts:[email protected]
- Rolecontacts.roleYextras_contacts:admin
Technical information
Update frequencyaccrualPeriodicityYextras_accrualPeriodicity:monthly
LineagelineageYextras_lineage:Lineage
Temporal ExtenttemporalCoverageYextras_temporalCoverage:coverage
Parent Dataset IdentifierderivedFromIdsYextras_derivedFromIds:("ID1" OR "ID2")
Child Dataset IdentifierusedByIdsYextras_usedByIds:("ID1" OR "ID2")
Data LanguagedatasetLanguageYextras_datasetLanguage:eng
Data Character SetdatasetCharacterSetYextras_datasetCharacterSet:utf8
Data FormatsdataFormatsYextras_dataFormats:("CSV" OR "PDF")
Spatial information
Spatial Representation TypecoordinateReferenceSystemIdYextras_coordinateReferenceSystemId:jhdhqwdhq
Geographic extentgeospatialExtentYextras_geospatialExtent:value
Metadata information
- Individual name
- Organisation NamemetadataContact.organisationNameYextras_metadataContact:NAthan
- Email AddressmetadataContact.emailAddressYextras_metadataContact:test@email
- RolemetadataContact.roleYextras_metadataContact:admin
Metadata LanguagemetadataLanguageYextras_metadataLanguage:eng
Metadata Character SetmetadataCharacterSetYextras_metadataCharacterSet:utc
Hierarchy LevelhierarchyLevelYextras_hierarchyLevel:level
Metadata Updated DatemetadataModifiedYextras_metadataModified:[01-12-2023]
Metadata Standard NamemetadataStandardNameYextras_metadataStandardName:na stand
Metadata Standard VersionmetadataStandardVersionYextras_metadataStandardVersion:v1
Data and Supporting Information
- URLresources.urlYextras_resources:http://www.test.com
- Nameresources.nameYextras_resources:my resource
- Descriptionresources.descriptionYextras_resources:This is...
Miscellaneous