Changeset 259
- Timestamp:
- 04/25/08 03:17:35 (7 months ago)
- Files:
-
- trunk/lib/picolena/templates/app/models/document.rb (modified) (2 diffs)
- trunk/lib/picolena/templates/app/models/finder.rb (modified) (1 diff)
- trunk/lib/picolena/templates/app/models/indexer.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/picolena/templates/app/models/document.rb
r247 r259 84 84 end 85 85 86 # Returns the id with which the document is indexed.87 def index_id88 @index_id ||= Finder.term_search(:complete_path, complete_path).doc89 end90 91 86 # Fields that are shared between every document. 92 87 def self.default_fields_for(complete_path) … … 106 101 # Useful to get meta-info about it. 107 102 def from_index 108 Indexer.index[ index_id]103 Indexer.index[probably_unique_id] 109 104 end 110 105 111 def self.find_by_unique_id(some_id) 112 doc_id=Finder.term_search(:probably_unique_id, some_id).doc 113 new(Indexer.index[doc_id][:complete_path]) 106 def self.find_by_unique_id(probably_unique_id) 107 new(Indexer.index[probably_unique_id][:complete_path]) 114 108 end 115 109 trunk/lib/picolena/templates/app/models/finder.rb
r247 r259 69 69 end 70 70 end 71 72 class<<self73 def searcher74 @@searcher ||= Ferret::Search::Searcher.new(Picolena::IndexSavePath)75 end76 77 def term_search(field,term)78 query = Ferret::Search::TermQuery.new(field,term)79 searcher.search(query).hits.first80 end81 71 82 def reload! 83 @@searcher = nil 84 @@index = nil 85 end 72 def self.reload! 73 @@index = nil 86 74 end 87 75 trunk/lib/picolena/templates/app/models/indexer.rb
r258 r259 109 109 :field_infos => default_field_infos, 110 110 # Great way to ensure that no file is indexed twice! 111 :key => : complete_path111 :key => :probably_unique_id 112 112 } 113 113 end
