예제 #1
0
        /// <summary>
        /// Delete index by name
        /// </summary>
        public async Task <bool> DeleteIndex(string indName)
        {
            DeleteIndexResponse resp = null;

            try
            {
                if (_client.Indices.Exists(indName).Exists)
                {
                    resp = await _client.Indices.DeleteAsync(indName);
                }
                else
                {
                    return(false);
                }

                _logger.LogInformation($"Index {indName} has been deleted");
            }
            catch (Exception)
            {
                _logger.LogError($"Failed to delete index {indName}");
                return(false);
            }

            return(resp.IsValid);
        }
        public async Task <IActionResult> Delete()
        {
            try
            {
                ExistsResponse indexExistsReponse = await _elasticClient.Indices.ExistsAsync(_appConfig.Elasticsearch.IndexName);

                if (indexExistsReponse.IsValid && indexExistsReponse.Exists)
                {
                    DeleteIndexResponse deleteIndexResult = await _elasticClient.Indices.DeleteAsync(_appConfig.Elasticsearch.IndexName);

                    if (!deleteIndexResult.IsValid)
                    {
                        _logger.LogError("Unable to delete employee index");
                        return(StatusCode(StatusCodes.Status500InternalServerError));
                    }
                }

                return(Ok());
            }
            catch (Exception ex)
            {
                _logger.LogError(1, ex, "Unable to delete Employees index; does not exists");
                return(BadRequest());
            }
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DeleteIndexResponse response = new DeleteIndexResponse();


            return(response);
        }
예제 #4
0
        /// <summary>
        /// 删除索引
        /// </summary>
        /// <returns></returns>
        public bool DeleteElasticClientIndex(string dbname)
        {
            DeleteIndexResponse deleteIndexResponse = client.Indices.Delete(dbname);
            var isdelete = deleteIndexResponse.Acknowledged;

            return(isdelete);
        }
        // DELETE api/values/5

        public async Task <IHttpActionResult> Delete(string id)
        {
            //StringResponse asyncIndexResponse = await lowLevelClient.Indices.DeleteAsync<Data>(value);
            DeleteIndexResponse asyncIndexResponse = await nestClient.Indices.DeleteAsync(id);

            return(Ok(content: asyncIndexResponse));
        }
예제 #6
0
        public HttpResponseMessage DeleteIndex(string index)
        {
            DeleteIndexResponse response = contactService.DeleteIndex(new DeleteIndexRequest()
            {
                Name = index
            });

            return(Request.BuildResponse(response));
        }
        public virtual async Task <bool> DeleteIndex()
        {
            DeleteIndexResponse response = null;

            if (_client.Indices.Exists(_index).Exists)
            {
                response = await _client.Indices.DeleteAsync(_index);
            }

            return(response.Acknowledged);
        }
예제 #8
0
        /// <summary>
        /// 删除索引
        /// </summary>
        /// <param name="indexName"></param>
        public DeleteIndexResponse DeleteIndex(string indexName)
        {
            DeleteIndexResponse response = this.Client.Indices.Delete(indexName);

            return(response);
        }
        /// <summary>
        /// 删除索引
        /// </summary>
        /// <param name="elasticClient"></param>
        /// <param name="indexName"></param>
        public static DeleteIndexResponse DeleteIndex(this IElasticClient elasticClient, string indexName)
        {
            DeleteIndexResponse response = elasticClient.Indices.Delete(indexName);

            return(response);
        }
예제 #10
0
 public virtual Task <bool> OnIndexDeleteFailure(string indexName, TimeSpan duration, DeleteIndexResponse response, Exception ex)
 {
     _logger.LogErrorRequest(ex, response, "Failed to delete index {IndexName} after {Duration:g}", indexName, duration);
     return(Task.FromResult(true));
 }