如何使用CKAN API通过多个标签搜索数据集? [英] How I search datasets by multiple tags using CKAN API?

查看:76
本文介绍了如何使用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 <-- 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:我使用了前10个标签(

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)

例如:

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

这篇关于如何使用CKAN API通过多个标签搜索数据集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆