Sha256: 5339c58e78841de970e5967a9df1cbc14d936446c491fb160226527756fac8a7
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
# Licensed to Elasticsearch B.V. under one or more contributor # license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright # ownership. Elasticsearch B.V. licenses this file to you under # the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # Indexer class for <http://sidekiq.org> # # Run me with: # # $ bundle exec sidekiq --queue elasticsearch --verbose # class Indexer include Sidekiq::Worker sidekiq_options queue: 'elasticsearch', retry: false, backtrace: true Logger = Sidekiq.logger.level == Logger::DEBUG ? Sidekiq.logger : nil Client = Elasticsearch::Client.new host: (ENV['ELASTICSEARCH_URL'] || 'http://localhost:9200'), logger: Logger def perform(operation, klass, record_id, options={}) logger.debug [operation, "#{klass}##{record_id} #{options.inspect}"] case operation.to_s when /index|update/ record = klass.constantize.find(record_id) record.__elasticsearch__.client = Client record.__elasticsearch__.__send__ "#{operation}_document" when /delete/ Client.delete index: klass.constantize.index_name, id: record_id else raise ArgumentError, "Unknown operation '#{operation}'" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
elasticsearch-rails-8.0.0 | lib/rails/templates/indexer.rb |
elasticsearch-rails-8.0.0.pre | lib/rails/templates/indexer.rb |