overriding Sunspot::Indexer.prepare to have different id field value
# in Rails place this in config/initializers/sunspot_indexer_prepare.rb | |
Sunspot::Indexer.module_eval do | |
alias :old_prepare :prepare | |
def prepare(model) | |
document = old_prepare(model) | |
document.fields_by_name(:id).first.value = document.fields_by_name(:filename).first.value | |
document | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment