Guest User

Untitled

a guest
Feb 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. require 'rubygems'
  2. require 'ferret'
  3.  
  4. system("rm -rf /tmp/index; mkdir -p /tmp/index")
  5. index = Ferret::Index::Index.new(:path => PATH, :key => :id, :auto_flush => false)
  6. 100.times do |i|
  7. doc = {}
  8. doc[:id] = i
  9. index << doc
  10. end
  11. index.flush
  12. result = index.search('id:*')
  13. puts "Total hits = #{result.total_hits}"
  14. 100.times do |i|
  15. doc = {}
  16. doc[:id] = i + 100
  17. index << doc
  18. end
  19. index.flush
  20. result = index.search('id:*')
  21. puts "Total hits = #{result.total_hits}"
Add Comment
Please, Sign In to add comment