RDF.rb - ruby sparql-client gem sparql 查询“选择”不工作
我正在使用 bendiken/sparql-client 进行 ruby 应用程序。当我执行给定的示例查询方法时它返回任何空数组结果。
查询方法如下:
require 'rubygems'
require 'sparql/client'
sparql = SPARQL::Client.new("http://dbpedia.org/sparql")
query = sparql.select.where([:s, :p, :o]).offset(100).limit(10)
query.each_solution do |solution|
puts solution.inspect
end
如果我执行以下查询,它会完美返回结果。
require 'rubygems'
require 'sparql/client'
sparql = SPARQL::Client.new("http://dbpedia.org/sparql")
queryString="SELECT * WHERE { ?s ?p ?o } OFFSET 100 LIMIT 10"
query= sparql.query(queryString)
query.each_solution do |solution|
puts solution.inspect
end
请让我知道为什么第一个查询方法不起作用。让我知道我是否错过了什么?
I am using the bendiken/sparql-client for ruby application.When I execute the given sample query methods its returning any empty array result.
The query method is as follow:
require 'rubygems'
require 'sparql/client'
sparql = SPARQL::Client.new("http://dbpedia.org/sparql")
query = sparql.select.where([:s, :p, :o]).offset(100).limit(10)
query.each_solution do |solution|
puts solution.inspect
end
If I execute with following query it is returning result perfectly .
require 'rubygems'
require 'sparql/client'
sparql = SPARQL::Client.new("http://dbpedia.org/sparql")
queryString="SELECT * WHERE { ?s ?p ?o } OFFSET 100 LIMIT 10"
query= sparql.query(queryString)
query.each_solution do |solution|
puts solution.inspect
end
Please Let me know why the first query method is not working.Let me know if any thing I have missed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道为什么你的第一个示例不起作用,因为它似乎与文档相符。它对我来说也不起作用,使用 0.0.9 sparql-client gem。但是,调用
query.execute
确实会运行查询。所以:对我有用
I don't know why your first sample does not work, since it does seem to match the documentation. It didn't work for me either, with the 0.0.9 sparql-client gem. However, calling
query.execute
does run the query. So:works for me