-
Notifications
You must be signed in to change notification settings - Fork 810
Open
Labels
@dixpac
Description
Indexer example:
class Indexer include Sidekiq::Worker sidekiq_options queue: 'elasticsearch', retry: false Logger = Sidekiq.logger.level == Logger::DEBUG ? Sidekiq.logger : nil Client = Elasticsearch::Client.new host: 'localhost:9200', logger: Logger def perform(operation, record_id) logger.debug [operation, "ID: #{record_id}"] case operation.to_s when /index/ record = Article.find(record_id) Client.index index: 'articles', type: 'article', id: record.id, body: record.__elasticsearch__.as_indexed_json when /delete/ begin Client.delete index: 'articles', type: 'article', id: record_id rescue Elasticsearch::Transport::Transport::Errors::NotFound logger.debug "Article not found, ID: #{record_id}" end else raise ArgumentError, "Unknown operation '#{operation}'" end end end
Doesn't work for me on ES 7. When I change the type from article -> _doc then it works:
Client.index index: 'articles', type: '_doc', id: record.id, body: record.__elasticsearch__.as_indexed_json #or Client.index index: 'articles' id: record.id, body: record.__elasticsearch__.as_indexed_json
Maybe I'm doing something wrong or this is expected change but didn't yet get into README since 7 branch is still not released. I'm just posting it here so maybe it can help someone.