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