如何使用CKAN API通过多个标签搜索数据集? [英] How I search datasets by multiple tags using CKAN API?
问题描述
我正在使用API版本为"ckan_version"的CKAN门户网站:"2.5.x"我的标签很少,我需要使用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.
可以使用do use package_search端点来搜索具有所有给定标签的软件包,但是它可以用作"AND"运算符,而我需要的是"OR"运算符.例如:
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.:
- http://demo.ckan.org/api/3/action/package_search?fq = tags:contabilidade-social <-返回11个包含"contabilidade-social"的软件包
- http://demo.ckan.org/api/3/action/package_search?fq = tags:contabilidade-social + governo <-返回11个包含"contabilidade-social"和"governo"的软件包
- http://demo.ckan.org/api/3/action/package_search?fq = tags:contabilidade-social + governo + enogastronomia <-返回0个包含"contabilidade-social","governo"和"enogastronomia"的软件包.出于我的目的,它应改为使用"OR"运算符返回匹配项.
- http://demo.ckan.org/api/3/action/package_search?fq=tags:contabilidade-social <-- return 11 packages that contains 'contabilidade-social'
- http://demo.ckan.org/api/3/action/package_search?fq=tags:contabilidade-social+governo <-- return 11 packages that contains 'contabilidade-social' and 'governo'
- http://demo.ckan.org/api/3/action/package_search?fq=tags:contabilidade-social+governo+enogastronomia <-- return 0 packages that contains 'contabilidade-social' and 'governo'and 'enogastronomia'. For my purpose it should return matches with 'OR' operator instead.
PS: I used top 10 tags (http://demo.ckan.org/api/action/package_search?facet.field=[%22tags%22]&facet.limit=10&rows=0).
我认为它与SOLR和postgresql索引有关.有办法吗?如果不是,是否可以扩展或创建一个方面以使使用这种搜索成为可能?
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?
推荐答案
尝试以下语法:
fq=tags:(tag1 OR tag2 OR tag3)
例如:
这篇关于如何使用CKAN API通过多个标签搜索数据集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!