Пример #1
0
        public IndicesResponse DeleteMapping <T>(string index, string type) where T : class
        {
            var path   = this.CreatePath(index, type);
            var status = this.Connection.DeleteSync(path);

            var response = new IndicesResponse();

            try
            {
                response = JsonConvert.DeserializeObject <IndicesResponse>(status.Result);
            }
            catch { }

            response.ConnectionStatus = status;
            return(response);
        }
Пример #2
0
        /// <summary>
        /// Deletes a mapping.
        /// </summary>
        /// <typeparam name="T">Mapped type.</typeparam>
        /// <returns>Response status information.</returns>
        public IndicesResponse DeleteMapping <T>() where T : class
        {
            var type   = this.InferTypeName <T>();
            var path   = this.createPath(this.Settings.DefaultIndex, type);
            var status = this.Connection.DeleteSync(path);

            var response = new IndicesResponse();

            try
            {
                response = JsonConvert.DeserializeObject <IndicesResponse>(status.Result);
            }
            catch { }

            response.ConnectionStatus = status;
            return(response);
        }
Пример #3
0
        public IndicesResponse CreateIndex(string index, IndexSettings settings)
        {
            string path     = this.CreatePath(index);
            string data     = JsonConvert.SerializeObject(settings, Formatting.None, this.SerializationSettings);
            var    status   = this.Connection.PostSync(path, data);
            var    response = new IndicesResponse();

            response.ConnectionStatus = status;
            try
            {
                response         = JsonConvert.DeserializeObject <IndicesResponse>(status.Result);
                response.IsValid = true;
            }
            catch (Exception e) {
            }
            return(response);
        }
Пример #4
0
        public IndicesResponse ClearCache(List <string> indices, ClearCacheOptions options)
        {
            string path = "/_cache/clear";

            if (indices != null && indices.Any(s => !string.IsNullOrEmpty(s)))
            {
                path = "/" + string.Join(",", indices.Where(s => !string.IsNullOrEmpty(s)).ToArray()) + path;
            }
            if (options != ClearCacheOptions.All)
            {
                var caches = new List <string>();
                if ((options & ClearCacheOptions.Id) == ClearCacheOptions.Id)
                {
                    caches.Add("id=true");
                }
                if ((options & ClearCacheOptions.Filter) == ClearCacheOptions.Filter)
                {
                    caches.Add("filter=true");
                }
                if ((options & ClearCacheOptions.FieldData) == ClearCacheOptions.FieldData)
                {
                    caches.Add("field_data=true");
                }
                if ((options & ClearCacheOptions.Bloom) == ClearCacheOptions.Bloom)
                {
                    caches.Add("bloom=true");
                }

                path += "?" + string.Join("&", caches.ToArray());
            }

            ConnectionStatus status = this.Connection.PostSync(path, string.Empty);
            var response            = new IndicesResponse();

            try
            {
                response         = JsonConvert.DeserializeObject <IndicesResponse>(status.Result);
                response.IsValid = true;
            }
            catch
            {
            }
            response.ConnectionStatus = status;
            return(response);
        }
Пример #5
0
        public IndicesResponse Map <T>(string index, string type) where T : class
        {
            string path = this.CreatePath(index, type) + "_mapping";
            string map  = this.CreateMapFor <T>(type);

            ConnectionStatus status = this.Connection.PutSync(path, map);

            var response = new IndicesResponse();

            try
            {
                response         = JsonConvert.DeserializeObject <IndicesResponse>(status.Result);
                response.IsValid = true;
            }
            catch
            {
            }

            response.ConnectionStatus = status;
            return(response);
        }