Google Groups

Re: [picky:99] facets?


David Lowenfels Jul 23, 2012 4:26 PM
Posted in group: Picky-Ruby
Now I'm getting weird results with the latest version (4.5.10)

> Product.class_eval("@@products_index").facets(:gender)
 => {"women"=>8.899, "men"=>8.76}

where are the decimals coming from??


def Product.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 ]
    end.select { |_, total| total > 0 }
end
> Product.facet(:gender,"climbing jacket")      => [["women", 5], ["men", 25]]

these facets total up to 30. (The query is much faster now with the new version, even before I reindexed. )
but this says 33:

Product.query("climbing jacket",1000).ids.count
 => 33


and may I suggest that uniq be incorporated into results#ids ?
ruby-1.9.3-p194 :051 > Product.query("climbing jacket",1000).ids.uniq.count
 => 22


-David