LeonanCarvalho
LeonanCarvalho

Reputation: 1869

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?

Upvotes: 2

Views: 1349

Answers (2)

Aaron M
Aaron M

Reputation: 142

If not using the API, then entering the search words separated by | and no spaces seems to work e.g. blue|red would return datasets with blue or red. e.g. dark blue|red also seems to work if one of the terms has a space in it.

Upvotes: 0

amercader
amercader

Reputation: 4540

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)

Upvotes: 5

Related Questions