Skip to content
This repository
tag: v4.0.9
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 23 lines (17 sloc) 0.587 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
require File.expand_path '../../../server/lib/picky', __FILE__

Person = Struct.new :id, :first, :last

# Loading the Picky index without a source,
# but purely by adding (replacing) items.
#
data = Picky::Index.new :people do
  category :first
  category :last
end

data.replace Person.new(1, 'Donald', 'Knuth')
data.replace Person.new(2, 'Niklaus', 'Wirth')
data.replace Person.new(3, 'Donald', 'Worth')
data.replace Person.new(4, 'Peter', 'Niklaus')

people = Picky::Search.new data

results = people.search 'donald'

# p results.allocations
fail __FILE__ unless results.ids == [3, 1]
Something went wrong with that request. Please try again.