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.
- 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.
- 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 key | Extra | Description | Example | Test Result |
---|---|---|---|---|---|
General | |||||
Title | title | N | Dataset Title | title:water | |
Alternative Titles | alternativeTitles | Y | Dataset Alternative title | extras_alternativeTitles:water | |
Summary | notes | N | Dataset description | notes:Water body measures are the actions | |
Organisation | extras_publisher_name | Y | extras_publisher_name:("Animal & Plant Health Agency") | ||
Category | category | Y | User defined category | extras_category:environment | |
Freetext Keywords | taxonomyKeywords | Y | extras_taxonomyKeywords:("water" OR "soil") | ||
Workflow keywords | workflowKeywords | Y | extras_workflowKeywords:("OpenData" OR "RetiredOpenData") | ||
Licence | license | Y | extras_license:("Open Government Licence") | ||
Attribution statement | licence.attributionStatement | Y | extras_licence:Environment Agency | ||
Use limitation statement | licence.useLimitationStatement | Y | extras_licence:Use Limitation Statement | ||
Publishing body | publisher | Y | extras_publisher_name:("Environment Agency") | ||
Creation date | createdAt | Y | extras_createdAt:18-02-2016 | ||
Publication date | published | Y | extras_published:[12-01-2000] | ||
Revision date | metadataModified | Y | extras_metadataModified:[12-01-2000] | ||
Draft status | draftStatus | Y | extras_draftStatus:Submitted | ||
Published status | publishedStatus | Y | extras_publishStatus:Published | ||
Contact information | |||||
- Individual name | contacts.individualName | Y | extras_contacts:Matt | ||
- Organisation name | contacts.organisationName | Y | extras_contacts:Environment Agency | ||
- Email address | contacts.emailAddress | Y | extras_contacts:[email protected] | ||
- Role | contacts.role | Y | extras_contacts:admin | ||
Technical information | |||||
Update frequency | accrualPeriodicity | Y | extras_accrualPeriodicity:monthly | ||
Lineage | lineage | Y | extras_lineage:Lineage | ||
Temporal Extent | temporalCoverage | Y | extras_temporalCoverage:coverage | ||
Parent Dataset Identifier | derivedFromIds | Y | extras_derivedFromIds:("ID1" OR "ID2") | ||
Child Dataset Identifier | usedByIds | Y | extras_usedByIds:("ID1" OR "ID2") | ||
Data Language | datasetLanguage | Y | extras_datasetLanguage:eng | ||
Data Character Set | datasetCharacterSet | Y | extras_datasetCharacterSet:utf8 | ||
Data Formats | dataFormats | Y | extras_dataFormats:("CSV" OR "PDF") | ||
Spatial information | |||||
Spatial Representation Type | coordinateReferenceSystemId | Y | extras_coordinateReferenceSystemId:jhdhqwdhq | ||
Geographic extent | geospatialExtent | Y | extras_geospatialExtent:value | ||
Metadata information | |||||
- Individual name | |||||
- Organisation Name | metadataContact.organisationName | Y | extras_metadataContact:NAthan | ||
- Email Address | metadataContact.emailAddress | Y | extras_metadataContact:test@email | ||
- Role | metadataContact.role | Y | extras_metadataContact:admin | ||
Metadata Language | metadataLanguage | Y | extras_metadataLanguage:eng | ||
Metadata Character Set | metadataCharacterSet | Y | extras_metadataCharacterSet:utc | ||
Hierarchy Level | hierarchyLevel | Y | extras_hierarchyLevel:level | ||
Metadata Updated Date | metadataModified | Y | extras_metadataModified:[01-12-2023] | ||
Metadata Standard Name | metadataStandardName | Y | extras_metadataStandardName:na stand | ||
Metadata Standard Version | metadataStandardVersion | Y | extras_metadataStandardVersion:v1 | ||
Data and Supporting Information | |||||
- URL | resources.url | Y | extras_resources:http://www.test.com | ||
- Name | resources.name | Y | extras_resources:my resource | ||
- Description | resources.description | Y | extras_resources:This is... | ||
Miscellaneous | |||||
Updated 10 months ago