On Apr 11, 2009, at 3:05 PM, Thanh Doan wrote:
We are also Evaluating Solr and Sphinx to see which one provides a
suitable
search solution for our ROR site.
As a newbie I picked the Advanced Rails Recipes book and follow
Recipe 27
before building our prototype.
As I followed Recipe 27 of the Advanced Rails Recipes book. I tried to
follow the steps exactly to see if I can drill down the search
results using
facets.
Initially solr and solr-ruby appeared to work fine. The below
statements
worked great and I was able to query the solr index from Ruby.
solr = Solr::Connection.new(’http://127.0.0.1:8983/solr’)
response = solr.query(’pragmatic’, :facets => {:fields =>
['pubisher_facet'], :mincount =>1}) docs = response.hits
But when I ran
response.facet_fields(’publisher_facet’)
I got the below error
response.field_facets(’publisher_facet’) NoMethodError: undefined
method
`size’ for nil:NilClass from
It's field_facets, not facet_fields. Using Solr's example data, solr-
ruby 0.0.7, and irb -
>> Solr::Connection.new.query('ipod', :facets => {:fields =>
['cat']}).field_facets('cat').each {|f| p "#{f.name} (#{f.value})"}
"electronics (3)"
"connector (2)"
"music (1)"
"camera (0)"
"card (0)"
"copier (0)"
"drive (0)"
"graphics (0)"
"hard (0)"
"memory (0)"
"monitor (0)"
"multifunction (0)"
"printer (0)"
"scanner (0)"
"search (0)"
"software (0)"
Erik