Created
January 24, 2012 09:50
-
-
Save rogerbraun/1669328 to your computer and use it in GitHub Desktop.
Test for a Picky bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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