Search Engine in a Script Tweet
ruby / picky / sinatra
This is a post about running Picky in a small script.
Design Philosopy
You all know that with Picky we want the full flexibility of Ruby.
What we also want is a search engine that runs with a minimal setup. Small and sweet. Portable, lightweight, bam!
In short: Picky wants to be the Sinatra of search engines. Did we achieve this? Not yet, but we are very close indeed.
Let’s have a quick dance in the rain.
The code
Go ahead and replace Picky with a very small script! You can copy, right? And paste? Ok. Go.
# Possible since Picky 3.2.0.
#
require 'picky'
include Picky
Thing = Struct.new :id, :name
index = Index.new :test do
category :name, similarity: Similarity::DoubleMetaphone.new(3)
end
index.replace Thing.new(1, 'Picky')
index.replace Thing.new(2, 'Parslet')
things = Search.new(index) do
boost [:name] => +3
end
p things.search("Pick").ids
p things.search("Pic").to_hash
p things.search("Parsley~").allocations
That’s it. Easy to just try something, and later evolve into a fully fleshed, super-powerful search engine.
Next Picky Update PerformanceShare
Previous Twitter Account