Google Groups

Re: [picky:122] facets?


David Lowenfels Jul 25, 2012 9:00 AM
Posted in group: Picky-Ruby
Here are my results with 4.5.12, which look different than yours :-/

products = Product.class_eval("@@products_index")
p products.facets :gender
p products.facets :gender, filter: 'keywords:climbing jacket'
p products.facets :gender, filter: 'climbing jacket'
{"women"=>7324, "men"=>6372}
{"women"=>7324, "men"=>6372}
{"women"=>7324, "men"=>6372}

products = Product.class_eval("@@products_search")
p products.facets :gender
p products.facets :gender, filter: 'keywords:climbing jacket'
p products.facets :gender, filter: 'climbing jacket'

{"women"=>7324, "men"=>6372}
{"women"=>4, "men"=>17}
{}


and my configuration:

  @@products_index = Picky::Index.new :products do
    source { Product.all }
    category :name, weight: 5
    category :brand, indexing: { splits_text_on: /$/ }
    category :keywords, weight: 4
    category :short_description, weight: 3
    category :colors, weight: 2
    category :sizes
    category :gender
  end

  @@products_search = Picky::Search.new @@products_index do
    ignore :colors
    ignore_unassigned_tokens
    boost [:brand_name, :product_name] => 2
    terminate_early
    max_allocations 4
     # searching max_words: 5
  end


On Jul 25, 2012, at 12:43 AM, Florian R. Hanke wrote:

> Hi David,
>
> I just tried to reproduce your results.
>
> Running
>
> p products.facets :gender
> p products.facets :gender, filter: 'keywords:climbing jacket'
> p products.facets :gender, filter: 'climbing jacket'
>
> with your data yields me
>
> {"women"=>7324, "men"=>6372}
> {"women"=>10, "men"=>47}
> {"women"=>10, "men"=>47}
>
> I'm using the latest Picky::Search#facets code.
>
> Does that help/look ok somehow?
>
> Cheers,
>    Florian
> On Wednesday, 25. July 2012 at 17:14, David Lowenfels wrote:
>
>>> 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]]
>