[英]Sunspot:solr - empty response
I'm trying to obtain response of solr for a given query. 我正在尝试获取给定查询的solr响应。 I've checked the solr query interface on localhost:8983 and its working fine, giving the required response to the queries. 我检查了localhost:8983上的solr查询接口,它的工作正常,对查询提供了所需的响应。 I want to select the productId field from each response and print it. 我想从每个响应中选择productId字段并进行打印。 Following is the code I'm using: 以下是我正在使用的代码:
#!/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
But it does not print anything, my response seems to be empty. 但是它什么也没打印,我的回答似乎是空的。 How can I fix this 我怎样才能解决这个问题
尝试将第16行更改为:
puts hit['productId']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.