Google Groups

Re: [picky:90] facets?


David Lowenfels Jul 20, 2012 1:54 PM
Posted in group: Picky-Ruby
okay, here's what a I have so far… it's works great but is very slow… 5 seconds!

ruby-1.9.3-p194 :001 > Product.facet(:brand_name,"climbing jacket")
 => [["mountain", 3], ["hardwear", 3], ["outdoor", 2], ["arc'teryx", 16], ["the", 2], ["north", 2], ["face", 2], ["marmot", 2], ["patagonia", 2], ["research", 2], ["norraana", 1], ["norrona", 1], ["rab", 1]]

this takes a whopping 5 seconds to process!!


class Product < ActiveRecord::Base
...
  def self.facet category, query=nil
    facet = @@products_index.facets(category)
    return facet unless query
    facet.map do |token, size|
      [token, query("#{query} #{category}:#{token.inspect}", 1000).total ] # I changed this to 1000 because the zeros that you had nulled everything out
    end.select { |_, total| total > 0 }
  end
end


also, for the indexing of :brand_name category I don't want the text to be split, just sucked in verbatim (and case insensitive I suppose) Can I configure splits_text_on per-category??

Thanks,
David