Using Picky for on-site Search

27 views
Skip to first unread message

Neil Gladstone

unread,
Nov 19, 2013, 1:59:48 PM11/19/13
to picky...@googlegroups.com
Hi, I have a feeling something similar to this question may have been asked before:

We are thinking of using Picky for the shop search that would make it possible to use Picky as the backend for the a the category navigation. For example, if someone searched for scarves under "clothing" it would return knitted scarves, crocheted scarves and other scarves based on information in the title, keywords and description.

Is something like this possible with Picky and would you have any suggestions for how to weight the search to make the answers more
relevant?

If you can point me in the right direction I would appreciate it.

Neil

Picky / Florian Hanke

unread,
Nov 19, 2013, 5:20:01 PM11/19/13
to picky...@googlegroups.com
Hi Neil,

Yes, this is possible with Picky.
What I am not sure about is: what is the item that is found? Is it a specific page?

Anyway, not that important. I'll just call it "thing" ;)

If I understand correctly, what you want to do is restrict results to a smaller set when somebody is in a certain category.

So the way to do this in Picky is to index the category with the thing.
Then, when searching, prepend "category:clothing" to a search, with your example "category:clothing scarves".
Picky would then only return scarves which also are in category "clothing".

If you gem install picky, you can run this example in a file, or in your editor:

-----
require 'picky'

Page = Struct.new :id, :category, :title, :keywords, :description

data = Picky::Index.new :pages do
  category :category, partial: Picky::Partial::None.new
  category :title
  category :keywords, tokenize: false, partial: Picky::Partial::None.new
  category :description
end

data.replace Page.new(1, 'scarves', 'Knitted Scarves', ['scarf', 'knit'], 'Usually handmade')
data.replace Page.new(2, 'shirts', 'Printed Shirts', ['shirt', 'print'], 'Multicolor printed')

pages = Picky::Search.new data

results = pages.search 'scarf', 20, 0
puts results
puts results.allocations

results = pages.search 'category:scarves knitted', 20, 0
puts results
puts results.allocations
-----

I hope this example helps with understanding.

All the best and good luck :)
   Florian 

Neil Gladstone

unread,
Nov 20, 2013, 9:15:53 AM11/20/13
to picky...@googlegroups.com
Florian, Thank you very much for your help.

Picky / Florian Hanke

unread,
Nov 20, 2013, 10:15:31 AM11/20/13
to picky...@googlegroups.com
My pleasure!
Reply all
Reply to author
Forward
0 new messages