太阳黑子:溶胶 - 空响应



我正在尝试为给定查询获取solr的响应。我已经检查了 localhost:8983 上的 solr 查询接口及其工作正常,为查询提供了所需的响应。我想从每个响应中选择 productId 字段并打印出来。以下是我正在使用的代码:

#!/usr/bin/ruby
# encoding: utf-8
require 'rubygems'
require 'solr'
solr = Solr::Connection.new('http://localhost:8983/solr')
response = solr.query('necklace')
puts "the response is:"
#puts response
puts "n"
response.each do |hit|
    puts hit['productId'] 
end

但它没有打印任何东西,我的回答似乎是空的。我该如何解决这个问题

尝试将第 16 行更改为:

  puts hit['productId']

最新更新