Incorrect parsing of facet counts

48 views
Skip to first unread message

Greg

unread,
May 5, 2011, 7:37:29 AM5/5/11
to rsolr
Hi all

I am using RSolr 1.0.0 with Solr 3.1.0 and am finding that when I do a
facet query, field value and counts are flattened into a single array.

For example:
http://pastebin.com/rTGGesFp

In this example, the field values and counts are returned as a single
array:
["20.0", 1, "40.0", 1, "60.0", 1]

I expected these to be returned as an array of hashes, each containing
the field value and count:
[{"20.0"=>1}, {"40.0"=>1}, {"60.0"=>1}]

Is this a bug?

Many thanks
Greg

Matt Mitchell

unread,
May 5, 2011, 8:58:53 AM5/5/11
to rs...@googlegroups.com
Hey Greg. Actually this isn't a bug, but an annoyance that stems from the actual Solr response writer implementation.

A super easy way to deal with this could something like:

response["facet_counts"]["facet_fields"].each do |field, set|
  puts "#{field} =>"
  set.each_slice(2) do |value,count|
    puts "#{value} => #{count}"
  end
  puts "---"
end

Hope that helps!

Matt


--
You received this message because you are subscribed to the Google Groups "rsolr" group.
To post to this group, send email to rs...@googlegroups.com.
To unsubscribe from this group, send email to rsolr+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rsolr?hl=en.


Greg

unread,
May 5, 2011, 9:21:23 AM5/5/11
to rs...@googlegroups.com
Thanks Matt, that worked perfectly!

If I submit a patch, is this something that you would consider merging into rsolr? Or is there a need for having this data presented as a single array?

Greg
Reply all
Reply to author
Forward
0 new messages