ckanaction

package_search

Searches for packages satisfying a given search criteria.

This action accepts Solr search query parameters (details below), and returns a dictionary of results, including dictized datasets that match the search criteria, a search count, and also facet information.

Solr Parameters:

For more in depth treatment of each parameter, please read the Solr Documentation.

This action accepts a subset of Solr's search query parameters.

The following advanced Solr parameters are supported as well. Note that some of these are only available on particular Solr versions. See Solr's dismax and edismax documentation for further details on them:

qf, wt, bf, boost, tie, defType, mm

Examples:

  • q=flood datasets containing the word flood, floods, or flooding
  • fq=tags:economy datasets with the tag economy
  • facet.field=["tags"] facet.limit=10 rows=0 top 10 tags

Title

There is an issue for the Body dropdown within this UI where an empty object {} is set for the facet field.

Please either remove this field by clicking "Open JSON editor" in the Body dropdown or set it to true (the default value) or false.

POST
package_search
Authorization<token>

CKAN API token

In: header

q?string

the solr query.

fq?string

any filter queries to apply. Note: +site_id:{ckan_site_id} is added to this string prior to the query being executed.

fq_list?array<string>

additional filter queries to apply.

sort?string

sorting of the search results. Default: 'score desc, metadata_modified desc'. As per the Solr documentation, this is a comma-separated string of field names and sort-orderings.

rows?integer

the maximum number of matching rows (datasets) to return. (default: 10, upper limit: 1000 unless set in site's configuration ckan.search.rows_max)

start?integer

the offset in the complete result for where the set of returned datasets should begin.

facet?boolean

whether to enable faceted results. Default: True

facet.mincount?integer

the minimum counts for facet fields should be included in the results.

facet.limit?integer

the maximum number of values the facet fields return. A negative value means unlimited. This can be set instance-wide with the search.facets.limit config option. Default is 50.

facet.field?array<string>

the fields to facet upon. Default empty. If empty, then the returned facet information is empty.

include_drafts?boolean

if True, draft datasets will be included in the results. A user will only be returned their own draft datasets, and a sysadmin will be returned all draft datasets. Optional, the default is False.

include_deleted?boolean

if True, deleted datasets will be included in the results (site configuration ckan.search.remove_deleted_packages must be set to False). Optional, the default is False.

include_private?boolean

if True, private datasets will be included in the results. Only private datasets from the user’s organizations will be returned and sysadmins will be returned all private datasets. Optional, the default is False.

use_default_schema?boolean

use default package schema instead of a custom schema defined with an IDatasetForm plugin (default: False)

curl -X POST "http://localhost:5000/api/3/action/package_search" \  -H "Content-Type: application/json" \  -d '{}'