Changeset 243
- Timestamp:
- 04/24/08 08:01:47 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/yet_another_index_structure/lib/picolena/templates/app/models/finder.rb
r241 r243 12 12 @per_page=results_per_page 13 13 @offset=(page.to_i-1)*results_per_page 14 index_should_have_documents 14 15 end 15 16 … … 69 70 end 70 71 71 class<<self 72 class<<self 72 73 def searcher 73 Ferret::Search::Searcher.new(Picolena::IndexSavePath)74 @@searcher ||= Ferret::Search::Searcher.new(Picolena::IndexSavePath) 74 75 end 75 76 … … 78 79 searcher.search(query).hits.first 79 80 end 81 82 def reload! 83 @@searcher = nil 84 @@index = nil 85 end 86 end 87 88 private 89 90 def index_should_have_documents 91 raise IndexError, "no document found" unless index.size > 0 80 92 end 81 93 end branches/yet_another_index_structure/lib/picolena/templates/app/models/indexer.rb
r242 r243 5 5 @@max_threads_number = 8 6 6 7 class << self 7 class << self 8 8 def index_every_directory(remove_first=false) 9 9 clear! if remove_first 10 # Forces Finder.searcher and Finder.index to be reloaded, by removing them from the cache. 11 Finder.reload! 10 12 log :debug => "Indexing every directory" 11 13 start=Time.now … … 72 74 73 75 def index 74 Ferret::I .new(default_index_params)76 Ferret::Index::Index.new(default_index_params) 75 77 end 76 78
