, lib/elasticsearch/api/actions/get.rb, lib/elasticsearch/api/actions/mget.rb, lib/elasticsearch/api/actions/info.rb, lib/elasticsearch/api/actions/bulk.rb, lib/elasticsearch/api/actions/ping.rb, lib/elasticsearch/api/actions/count.rb, lib/elasticsearch/api/actions/index.rb, lib/elasticsearch/api/actions/scroll.rb, lib/elasticsearch/api/actions/exists.rb, lib/elasticsearch/api/actions/update.rb, lib/elasticsearch/api/actions/delete.rb, lib/elasticsearch/api/actions/search.rb, lib/elasticsearch/api/actions/create.rb, lib/elasticsearch/api/actions/msearch.rb, lib/elasticsearch/api/actions/reindex.rb, lib/elasticsearch/api/actions/explain.rb, lib/elasticsearch/api/actions/suggest.rb, lib/elasticsearch/api/actions/percolate.rb, lib/elasticsearch/api/actions/benchmark.rb, lib/elasticsearch/api/actions/get_source.rb, lib/elasticsearch/api/actions/put_script.rb, lib/elasticsearch/api/actions/mpercolate.rb, lib/elasticsearch/api/actions/get_script.rb, lib/elasticsearch/api/actions/termvectors.rb, lib/elasticsearch/api/actions/field_stats.rb, lib/elasticsearch/api/actions/mtermvectors.rb, lib/elasticsearch/api/actions/get_template.rb, lib/elasticsearch/api/actions/put_template.rb, lib/elasticsearch/api/actions/clear_scroll.rb, lib/elasticsearch/api/actions/search_exists.rb, lib/elasticsearch/api/actions/delete_script.rb, lib/elasticsearch/api/actions/search_shards.rb, lib/elasticsearch/api/actions/search_template.rb, lib/elasticsearch/api/actions/list_benchmarks.rb, lib/elasticsearch/api/actions/delete_template.rb, lib/elasticsearch/api/actions/update_by_query.rb, lib/elasticsearch/api/actions/abort_benchmark.rb, lib/elasticsearch/api/actions/delete_by_query.rb, lib/elasticsearch/api/actions/count_percolate.rb, lib/elasticsearch/api/actions/render_search_Perform multiple index, delete or update operations in a single request.
Supports various different formats of the payload: Array of Strings, Header/Data pairs, or the conveniency “combined” format where data is passed along with the header in a single item in a custom `:data` key. Provide the query either as a “query string” query in the `:q` argument, or using the Elasticsearch's [Query DSL]( in the `:body` argument.
The update method on the Image object accepts the keys and values from the submitted form data to update each Image model.
The rest of the code collects errors, and redirects the user back to the form action.
“Scrolling” the results is frequently used with the `scan` search type.
Return documents matching a query, as well as aggregations (facets), highlighted snippets, suggestions, etc.
Consider appending your additional attributes to the array and then tweaking the eligible attributes logic.
Also consider implementing a maximum number of records which are able to be bulk edited at a time; wouldn't want your server to time out.
Keep in mind this example does not make good use of mass assignment protection using .For my rails photo gallery site I needed the ability to bulk add descriptions and tags to my images.Finding, loading, editing, saving each photo individually is painful.Let's tweak this a bit further.# app/controllers/bulk_edit_def new @foos = Foo.find(params[:foo_ids]) matching_attributes = Foo.matching_attributes_from(@foos) @foo = Foo.new(matching_attributes) end # app/models/def self.matching_attributes_from(foos) matching = attriubtes_to_match = attribute_names #see attribute_names for more details do |foo| attributes_to_do |attribute| value = foo.__send__(attribute) #see send, invokes the method identified by symbol, use underscore version to avoid namespace issues if matching[attribute].nil?matching[attribute] = value #assume it's a match elsif matching[attribute] !
Send either a partial document (`doc` ) which will be deeply merged into an existing document, or a `script`, which will update the document content, in the `:body` argument.