Sha256: 9bcc9276dddf3cc3ad201b72cb7f5c18f31d254df1c723ec5c6439825c7072df

Contents?: true

Size: 730 Bytes

Versions: 2

Compression:

Stored size: 730 Bytes

Contents

namespace :best_bets do
  desc 'Update the BestBets SOLR index from best_bets.yml'
  task :update_index => :environment do
    best_bets_yaml = File.join Rails.root, "/config/best_bets.yml"
    best_bets = YAML.load_file(best_bets_yaml)['best_bets']

    solr = RSolr.connect :url => QuickSearch::Engine::APP_CONFIG['best_bets']['solr_url']

    solr.delete_by_query('*:*') 

    records = []

    best_bets.each do |id, value|
        record = {
            :id => id,
            :title => value['title'],
            :url => value['url'],
            :description => value['description'],
            :keywords => value['keywords']
        }
        records << record
    end

    solr.add(records)
    solr.commit

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quick_search-core-0.0.1 lib/tasks/best_bets.rake
quick_search-core-0.0.1.test lib/tasks/best_bets.rake