Ferret Indexing Script used by MyFirstBenchmark

require 'ferret'
require 'find'
include Ferret::Document

@index = Ferret::Index::Index.new(:path => '/home/janprill/searchtest/ferretindex')

def createIndex(inRepositoryPath)
    Find.find(inRepositoryPath) do |path|
        puts path
        if FileTest.file?(path)
            File.open(path) do |file|
                doc = Document.new()
                doc << Field.new(:file, path,
                              Field::Store::YES, Field::Index::UNTOKENIZED)
                doc << Field.new(:content, file.readlines,
                              Field::Store::NO, Field::Index::TOKENIZED)
                @index << doc
            end
        end
    end
end

started = Time.now
createIndex('/home/janprill/searchtest/files')
ended = Time.now
puts "start: #{started.to_s}, end: #{ended.to_s}"