Changeset 259

Show
Ignore:
Timestamp:
04/25/08 03:17:35 (7 months ago)
Author:
eric.dumin..@gmail.com
Message:

:key => :probably_unique_id was the solution. :)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/picolena/templates/app/models/document.rb

    r247 r259  
    8484  end 
    8585   
    86   # Returns the id with which the document is indexed. 
    87   def index_id 
    88     @index_id ||= Finder.term_search(:complete_path, complete_path).doc 
    89   end 
    90    
    9186  # Fields that are shared between every document. 
    9287  def self.default_fields_for(complete_path) 
     
    106101  # Useful to get meta-info about it. 
    107102  def from_index 
    108     Indexer.index[index_id] 
     103    Indexer.index[probably_unique_id] 
    109104  end 
    110105   
    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]) 
    114108  end 
    115109  
  • trunk/lib/picolena/templates/app/models/finder.rb

    r247 r259  
    6969    end 
    7070  end 
    71    
    72   class<<self   
    73     def searcher 
    74       @@searcher ||= Ferret::Search::Searcher.new(Picolena::IndexSavePath) 
    75     end 
    76      
    77     def term_search(field,term) 
    78       query = Ferret::Search::TermQuery.new(field,term) 
    79       searcher.search(query).hits.first 
    80     end 
    8171 
    82     def reload! 
    83       @@searcher = nil 
    84       @@index    = nil 
    85     end 
     72  def self.reload! 
     73    @@index = nil 
    8674  end 
    8775   
  • trunk/lib/picolena/templates/app/models/indexer.rb

    r258 r259  
    109109        :field_infos => default_field_infos, 
    110110        # Great way to ensure that no file is indexed twice! 
    111         :key         => :complete_path 
     111        :key         => :probably_unique_id 
    112112        } 
    113113    end