Skip to content

Instantly share code, notes, and snippets.

@rogerbraun
Created January 24, 2012 09:50
Show Gist options
  • Save rogerbraun/1669328 to your computer and use it in GitHub Desktop.
Save rogerbraun/1669328 to your computer and use it in GitHub Desktop.
Test for a Picky bug
require "picky"
class JapanObject
attr_accessor :id
@@id = 0
def initialize
@id = @@id +=1
end
def method_missing(name, *args)
"Japan"
end
end
JapanIndex = Picky::Index.new :japan do
category :title
category :theme
end
JapanSearch = Picky::Search.new JapanIndex
puts "Indexing..."
(1..1000).map{JapanObject.new}.each do |jo|
JapanIndex.replace(jo)
end
puts "Searching..."
puts
searches = ["japan", "title:japan"]
searches.each do |word|
puts "Searching for '#{word}'"
res = JapanSearch.search word, 1000000
puts "Total: #{res.total}"
puts "Returned IDs: #{res.ids.count}"
end
puts
searches.each do |word|
puts "Searching for '#{word}'"
res = JapanSearch.search word, 1000000
puts "Total: #{res.total}"
puts "Returned IDs: #{res.ids(100000).count}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment