Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

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

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

# An example where you give the Picky index
# an #each source.
#
data = Picky::Index.new :people do
  source do
    [Person.new(1, 'Donald', 'Knuth'),
     Person.new(2, 'Niklaus', 'Wirth'),
     Person.new(3, 'Donald', 'Worth'),
     Person.new(4, 'Peter', 'Niklaus')]
  end
  category :first
  category :last
end

people = Picky::Search.new data

data.reindex # == data.index; data.load

results = people.search 'donald'

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