def delete_by_query(query, params = nil, request_options = {})
      raise ArgumentError.new('query cannot be nil, use the `clear` method to wipe the entire index') if query.nil? && params.nil?
      params = sanitized_delete_by_query_params(params)

      params[:query] = query
      params[:hitsPerPage] = 1000
      params[:distinct] = false
      params[:attributesToRetrieve] = ['objectID']
      params[:cursor] = ''
      ids = []

      while params[:cursor] != nil
        result = browse(params, nil, request_options)

        params[:cursor] = result['cursor']

        hits = result['hits']
        break if hits.empty?

        ids += hits.map { |hit| hit['objectID'] }
      end

      delete_objects(ids, request_options)
    end
def delete_by_query(query, params = nil, request_options = {})
      raise ArgumentError.new('query cannot be nil, use the `clear` method to wipe the entire index') if query.nil? && params.nil?
      params = sanitized_delete_by_query_params(params)

      params[:query] = query
      params[:hitsPerPage] = 1000
      params[:distinct] = false
      params[:attributesToRetrieve] = ['objectID']
      params[:cursor] = ''
      ids = []

      while params[:cursor] != nil
        result = browse(params, nil, request_options)

        params[:cursor] = result['cursor']

        hits = result['hits']
        break if hits.empty?

        ids += hits.map { |hit| hit['objectID'] }
      end

      delete_objects(ids, request_options)
    end
Delete all objects matching a query
 This method retrieves all objects synchronously but deletes in batch
 asynchronously

 @param query the query string
 @param params the optional query parameters
 @param request_options contains extra parameters to send with your query