Search code examples
postgresqlapisolrckan

How I search datasets by multiple tags using CKAN API?


I'm using CKAN portal with API version "ckan_version": "2.5.x" I have few tags and I need to send using API these tags and I need to return a list of matching entries of packages or resources.

Is possible to use do use package_search endpoint to search for packages with all given tags, but it works as "AND" operator, and that I need is a "OR" operator. e.g.:

PS: I used top 10 tags (http://demo.ckan.org/api/action/package_search?facet.field=[%22tags%22]&facet.limit=10&rows=0).

I think it have relation with SOLR and postgresql index. There is a way to do that? If not, Is possible to extend or create a facet that make possible use this kind of search?


Solution

  • Try the following syntax:

    fq=tags:(tag1 OR tag2 OR tag3)
    

    For instance:

    http://demo.ckan.org/api/3/action/package_search?fq=tags:(contabilidade-social%20OR%20governo%20OR%20enogastronomia)