Skip to content

Instantly share code, notes, and snippets.

@jelder
Created March 5, 2014 20:14
Show Gist options
  • Save jelder/9375649 to your computer and use it in GitHub Desktop.
Save jelder/9375649 to your computer and use it in GitHub Desktop.
Prevent deleted objects in ElasticSearch from causing problems
module Tire
module Results
class Collection
def __find_records_by_ids(klass, ids)
records = @options[:load] === true ? klass.where(klass.primary_key => ids) : klass.find(ids, @options[:load])
@response['hits']['hits'].keep_if { |hit| records.map(&:id).include? hit["_id"].to_i }
records
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment