Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- solr = RSolr.connect
- response = solr.select :params => {:q => '*:*', :facet => true, 'facet.field' => 'price'}
- => {"responseHeader"=>{"status"=>0, "QTime"=>2, "params"=>{"facet"=>"true", "facet.field"=>"price", "wt"=>"ruby", "q"=>"*:*"}}, "response"=>{"numFound"=>3, "start"=>0, "docs"=>[{"id"=>"1", "price"=>20.0}, {"id"=>"2", "price"=>40.0}, {"id"=>"3", "price"=>60.0}]}, "facet_counts"=>{"facet_queries"=>{}, "facet_fields"=>{"price"=>["20.0", 1, "40.0", 1, "60.0", 1]}, "facet_dates"=>{}, "facet_ranges"=>{}}}
- response['facet_counts']['facet_fields']['price']
- => ["20.0", 1, "40.0", 1, "60.0", 1]
- # Expected result: [{"20.0"=>1}, {"40.0"=>1}, {"60.0"=>1}]
Advertisement
Add Comment
Please, Sign In to add comment