Changeset 288

Show
Ignore:
Timestamp:
04/28/08 03:41:27 (7 months ago)
Author:
eric.dumin..@gmail.com
Message:

Using :complete_path as key instead of base26_hash.
Not working for filenames with space inside though, because of Ferret :: Analysis :: AsciiWhiteSpaceAnalyzer?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/log_indexing_time_with_ferret/lib/picolena/templates/lib/indexing_time.rb

    r287 r288  
    22  class<<self 
    33    def add(complete_path) 
    4       log<<{:complete_path => complete_path, :indexing_time => Time.now.to_i, :id => complete_path.base26_hash
     4      log<<{:complete_path => complete_path, :indexing_time => Time.now.to_i
    55    end 
    66     
    77    def retrieve(complete_path) 
    8       it=log[complete_path.base26_hash
     8      it=log[complete_path
    99      it.nil? ? Time.at(0) : Time.at(it[:indexing_time].to_i) 
    1010    end 
     
    1919     
    2020    def log 
    21       @@log ||= Ferret::Index::Index.new(:path=>path, :fields=>fields, :key => :id
     21      @@log ||= Ferret::Index::Index.new(:path=>path, :fields=>fields, :key => :complete_path, :analyzer => analyzer
    2222    end 
    2323     
     
    3434      # Closes log to ensure consistency. 
    3535      close_log 
     36      # Reopens log and retrieve every single document. 
    3637      log.search(Ferret::Search::MatchAllQuery.new, :limit => :all).hits 
    3738    end 
    3839     
    3940    private 
     41     
     42    def analyzer 
     43      Ferret::Analysis::AsciiWhiteSpaceAnalyzer.new 
     44    end 
    4045     
    4146    def path 
     
    4449     
    4550    def fields 
    46       returning Ferret::Index::FieldInfos.new do |field_infos| 
    47         field_infos.add_field(:complete_path, :store => :yes, :index => :yes) 
    48         field_infos.add_field(:indexing_time, :store => :yes, :index => :yes) 
    49         field_infos.add_field(:id, :store => :yes, :index => :untokenized) 
     51      returning Ferret::Index::FieldInfos.new(:index => :untokenized_omit_norms, :term_vector => :no) do |field_infos| 
     52        field_infos.add_field(:complete_path) 
     53        field_infos.add_field(:indexing_time) 
    5054      end     
    5155    end