I'm attempting to do a bulk delete by ids and it appears to be not working. When I run my test suite and try via the Rails console, it seems to work OK. However, I'm running into occurrences where there are documents that simply don't get removed. The response however, indicates 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 mapping looks like:
tire.settings ElasticSearchAnalysis do
mapping _all: { enabled: false } do
indexes :id, type: "integer"
end
end
Sample HTTP DELETE:
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
When unescaped, the query looks like:
{\"filtered\":{\"query\":{\"match_all\":{}},\"filter\":{\"and\":[{\"terms\":{\"_id\":[587965789,587965791}}]}}}