How to create an elasticsearch index for a view in MYSQL ?
I tried making a model for a migration of a mysql view and in the model put
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
and put in elasticsearch.rb
unless client.indices.exists? index: 'history_views'
HistoryView.__elasticsearch__.create_index!
end
HistoryView.import
but it seems that the line HistoryView.import
gives an error
ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'history_views.' in 'order clause': SELECT history_views.* FROM history_views ORDER BY history_views. ASC LIMIT 1000
I think the gem needs a primary key to order by it and that is not present in the view .
How can I solve this ? Do I have to override some function in the gem ?