I am trying to do a bulk deletion using ids and does not seem to work. When I run my test suite and try through the Rails console, it works fine. However, I come across cases when there are documents that simply cannot be deleted. However, the answer indicates that it was successful.
Using tire 0.5.8, curb 0.8.4, ElasticSearch 0.90.2.
query = Tire::Search::Search.new do query do filtered do query { all } filter(:terms, _id: ids_array) end end end Curl::Easy.http_delete("#{index.url}/_query?source=#{Tire::Utils.escape(query.to_hash[:query].to_json)}") do |curb| curb.http_auth_types = :basic curb.username = ENV["ELASTICSEARCH_USERNAME"] curb.password = ENV["ELASTICSEARCH_PASSWORD"] end
The model display is as follows:
tire.settings ElasticSearchAnalysis do mapping _all: { enabled: false } do indexes :id, type: "integer" end end
HTTP DELETE example:
DELETE /production_shifts/_query?source=%7B%22filtered%22%3A%7B%22query%22%3A%7B%22match_all%22%3A%7B%7D%7D%2C%22filter%22%3A%7B%22and%22%3A%5B%7B%22terms%22%3A%7B%22_id%22%3A%5B587965789%2C587965791%7D%7D%5D%7D%7D%7D
If the request fails, the request looks like this:
{\"filtered\":{\"query\":{\"match_all\":{}},\"filter\":{\"and\":[{\"terms\":{\"_id\":[587965789,587965791}}]}}}
source share