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
On Jul 23, 2012, at 5:31 PM, Picky / Florian Hanke wrote:
> Facets (as I added them in in 4.5.9+) use the indexed weights instead of the ids sizes.
> Also see https://github.com/floere/picky/blob/master/history.textile (4.5.9) for details.
> Product.class_eval("@@products_search").facets(:gender)
=> {"women"=>8.899, "men"=>8.76}
how do I convert this from weights to numbers? Weights don't seem to be very useful to me as an end user…
or do I need to use the code I was using previously to do the sub filter? (see bottom of message)
> Product.class_eval("@@products_search").facets(:gender, filter:"climbing jacket")
=> {}
why am I getting an empty hash for this? I was expecting this would give me the same as my previous code.
> Picky::Search#search has the signature:
> def search text, ids = 20, offset = 0, options = {}
> If you pass in unique: true in the options, it will return unique results. It will be unique top down. That is, id an id has been used for one allocation of categories, eg. [:name, :surname], it will not be used anymore in a following allocation.
okay. I never saw this before because I didn't dig into the code.
shouldn't this method be explained on http://florianhanke.com/picky/documentation.html ?
even in the rdoc there is no mention of options[:unique]
Product.facets(:gender)=> {"women"=>7324, "men"=>6372}Product.facets(:gender, filter:"climbing jacket")=> {}not sure why I'm getting an empty hash here??
Product.facets(:gender, filter:"keywords:climbing jacket")=> {"women"=>4, "men"=>17}it only works when I specify the category to filter, but there are other matches which come on a more global query when not scoped by category.
i.e. this is the result of my previous code which works by subqueries:Product.facet(:gender, "climbing jacket")=> [["women", 9], ["men", 19]]
On Wednesday, 25. July 2012 at 17:14, David Lowenfels wrote:
On Wednesday, 25. July 2012 at 17:14, David Lowenfels wrote:
Yes, the 28 results appear to be good. FYI I am using the search object, not the index.
> Product.facet(:gender,"climbing jacket")
=> [["women", 9], ["men", 19]]