public static void SetRouteParameters <TParameters>( IQueryPath <TParameters> path, IConnectionSettingsValues settings, ElasticsearchPathInfo <TParameters> pathInfo) where TParameters : IRequestParameters, new() { var inferrer = new ElasticInferrer(settings); if (path.Types.HasAny()) { pathInfo.Type = inferrer.TypeNames(path.Types); } else if (path.AllTypes.GetValueOrDefault(false)) { pathInfo.Type = null; } if (path.Indices.HasAny()) { pathInfo.Index = inferrer.IndexNames(path.Indices); } else if (path.AllIndices.GetValueOrDefault(false) && !pathInfo.Type.IsNullOrEmpty()) { pathInfo.Index = "_all"; } else if (!path.AllIndices.GetValueOrDefault(false) && pathInfo.Index.IsNullOrEmpty()) { pathInfo.Index = inferrer.DefaultIndex; } }
internal virtual ElasticsearchPathInfo <TParameters> ToPathInfo(IConnectionSettingsValues settings, TParameters queryString) { var inferrer = new ElasticInferrer(settings); if (!this._AllIndices.HasValue && this._Indices == null) { this._Indices = new[] { (IndexNameMarker)inferrer.DefaultIndex } } ; if (this._Name.IsNullOrEmpty()) { throw new DslException("missing Repository()"); } var indices = this._Indices.HasAny() ? inferrer.IndexNames(this._Indices) : this._AllIndices.GetValueOrDefault(false) ? "_all" : inferrer.DefaultIndex; var types = this._Types.HasAny() ? inferrer.TypeNames(this._Types) : null; var pathInfo = base.ToPathInfo(queryString); pathInfo.Index = indices; pathInfo.Type = types; pathInfo.Name = this._Name; return(pathInfo); } }
public static void SetRouteParameters <TParameters>( IIndicesOptionalTypesNamePath <TParameters> path, IConnectionSettingsValues settings, ElasticsearchPathInfo <TParameters> pathInfo) where TParameters : IRequestParameters, new() { var inferrer = new ElasticInferrer(settings); if (!path.AllIndices.HasValue && path.Indices == null) { path.Indices = new[] { (IndexNameMarker)inferrer.DefaultIndex } } ; if (path.Name.IsNullOrEmpty()) { throw new DslException("missing Repository()"); } var indices = path.Indices.HasAny() ? inferrer.IndexNames(path.Indices) : path.AllIndices.GetValueOrDefault(false) ? "_all" : inferrer.DefaultIndex; var types = path.Types.HasAny() ? inferrer.TypeNames(path.Types) : null; pathInfo.Index = indices; pathInfo.Type = types; pathInfo.Name = path.Name; } }
public static void Update(IConnectionSettingsValues settings, ElasticsearchPathInfo <IndicesStatsRequestParameters> pathInfo, IIndicesStatsRequest request) { if (request.Types.HasAny()) { var inferrer = new ElasticInferrer(settings); var types = inferrer.TypeNames(request.Types); pathInfo.RequestParameters.AddQueryString("types", string.Join(",", types)); } if (request.Metrics != null) { pathInfo.Metric = request.Metrics.Cast <Enum>().GetStringValue(); } pathInfo.HttpMethod = PathInfoHttpMethod.GET; }
ElasticsearchPathInfo <SearchQueryString> IPathInfo <SearchQueryString> .ToPathInfo(IConnectionSettings settings) { var pathInfo = new ElasticsearchPathInfo <SearchQueryString>(); pathInfo.HttpMethod = this._QueryString.ContainsKey("source") ? PathInfoHttpMethod.GET : PathInfoHttpMethod.POST; pathInfo.QueryString = this._QueryString; var inferrer = new ElasticInferrer(settings); string indices; if (this._AllIndices.GetValueOrDefault(false)) { indices = !this._AllTypes.GetValueOrDefault(false) ? "_all" : null; } else if (this._Indices.HasAny()) { indices = inferrer.IndexNames(this._Indices); } else { indices = inferrer.IndexName <T>(); } string types; if (this._AllTypes.GetValueOrDefault(false)) { types = null; } else if (this._Types.HasAny()) { types = inferrer.TypeNames(this._Types); } else { types = inferrer.TypeName <T>(); } pathInfo.Index = indices; pathInfo.Type = types; return(pathInfo); }
internal virtual ElasticsearchPathInfo <K> ToPathInfo <K>(IConnectionSettingsValues settings, K queryString) where K : FluentRequestParameters <K>, new() { //start out with defaults var inferrer = new ElasticInferrer(settings); var index = inferrer.IndexName <T>(); var type = inferrer.TypeName <T>(); var pathInfo = new ElasticsearchPathInfo <K>() { Index = index, Type = type }; if (this._Types.HasAny()) { pathInfo.Type = inferrer.TypeNames(this._Types); } else if (this._AllTypes) { pathInfo.Type = null; } else { pathInfo.Type = inferrer.TypeName <T>(); } if (this._Indices.HasAny()) { pathInfo.Index = inferrer.IndexNames(this._Indices); } else if (this._AllIndices && !pathInfo.Type.IsNullOrEmpty()) { pathInfo.Index = "_all"; } else { pathInfo.Index = this._AllIndices ? null : inferrer.IndexName <T>(); } pathInfo.RequestParameters = queryString ?? new K(); pathInfo.RequestParameters.RequestConfiguration(r => this._RequestConfiguration); return(pathInfo); }
ElasticsearchPathInfo <IndicesStatsRequestParameters> IPathInfo <IndicesStatsRequestParameters> .ToPathInfo(IConnectionSettingsValues settings) { var pathInfo = base.ToPathInfo <IndicesStatsRequestParameters>(settings, this._QueryString); if (this._Types.HasAny()) { var inferrer = new ElasticInferrer(settings); var types = inferrer.TypeNames(this._Types); this._QueryString.AddQueryString("types", string.Join(",", types)); } if (this._Metrics != null) { pathInfo.Metric = this._Metrics.Cast <Enum>().GetStringValue(); } pathInfo.HttpMethod = PathInfoHttpMethod.GET; return(pathInfo); }
/// <summary> /// _msearch needs a specialized json format in the body /// </summary> public string SerializeMultiSearch(MultiSearchDescriptor multiSearchDescriptor) { var sb = new StringBuilder(); var inferrer = new ElasticInferrer(this._settings); foreach (var operation in multiSearchDescriptor._Operations.Values) { var indices = inferrer.IndexNames(operation._Indices); if (operation._AllIndices.GetValueOrDefault(false)) { indices = "_all"; } var index = indices ?? inferrer.IndexName(multiSearchDescriptor._Index) ?? inferrer.IndexName(operation._ClrType); var types = inferrer.TypeNames(operation._Types); var typeName = types ?? inferrer.TypeName(multiSearchDescriptor._Type) ?? inferrer.TypeName(operation._ClrType); if (operation._AllTypes.GetValueOrDefault(false)) { typeName = null; //force empty typename so we'll query all types. } var op = new { index = index, type = typeName, search_type = this.GetSearchType(operation, multiSearchDescriptor), preference = operation._Preference, routing = operation._Routing }; var opJson = this.Serialize(op, SerializationFormatting.None).Utf8String(); var action = "{0}\n".F(opJson); sb.Append(action); var searchJson = this.Serialize(operation, SerializationFormatting.None).Utf8String(); sb.Append(searchJson + "\n"); } var json = sb.ToString(); return(json); }
public static void SetRouteParameters <TParameters, T>( IQueryPath <TParameters> path, IConnectionSettingsValues settings, ElasticsearchPathInfo <TParameters> pathInfo) where TParameters : IRequestParameters, new() where T : class { //start out with defaults var inferrer = new ElasticInferrer(settings); var index = inferrer.IndexName <T>(); var type = inferrer.TypeName <T>(); pathInfo.Index = index; pathInfo.Type = type; if (path.Types.HasAny()) { pathInfo.Type = inferrer.TypeNames(path.Types); } else if (path.AllTypes.GetValueOrDefault(false)) { pathInfo.Type = null; } else { pathInfo.Type = inferrer.TypeName <T>(); } if (path.Indices.HasAny()) { pathInfo.Index = inferrer.IndexNames(path.Indices); } else if (path.AllIndices.GetValueOrDefault(false) && !pathInfo.Type.IsNullOrEmpty()) { pathInfo.Index = "_all"; } else { pathInfo.Index = path.AllIndices.GetValueOrDefault(false) ? null : inferrer.IndexName <T>(); } }
internal virtual ElasticsearchPathInfo <TParameters> ToPathInfo(IConnectionSettingsValues settings, TParameters queryString) { //start out with defaults var inferrer = new ElasticInferrer(settings); var index = inferrer.IndexName <T>(); var type = inferrer.TypeName <T>(); var pathInfo = base.ToPathInfo(queryString); pathInfo.Index = index; pathInfo.Type = type; if (this._Types.HasAny()) { pathInfo.Type = inferrer.TypeNames(this._Types); } else if (this._AllTypes) { pathInfo.Type = null; } else { pathInfo.Type = inferrer.TypeName <T>(); } if (this._Indices.HasAny()) { pathInfo.Index = inferrer.IndexNames(this._Indices); } else if (this._AllIndices && !pathInfo.Type.IsNullOrEmpty()) { pathInfo.Index = "_all"; } else { pathInfo.Index = this._AllIndices ? null : inferrer.IndexName <T>(); } return(pathInfo); }
internal virtual ElasticsearchPathInfo <K> ToPathInfo <K>(IConnectionSettingsValues settings, K queryString) where K : FluentRequestParameters <K>, new() { var inferrer = new ElasticInferrer(settings); if (!this._AllIndices.HasValue && this._Indices == null) { this._Indices = new[] { (IndexNameMarker)inferrer.DefaultIndex } } ; if (this._Name.IsNullOrEmpty()) { throw new DslException("missing Repository()"); } var indices = this._Indices.HasAny() ? inferrer.IndexNames(this._Indices) : this._AllIndices.GetValueOrDefault(false) ? "_all" : inferrer.DefaultIndex; var types = this._Types.HasAny() ? inferrer.TypeNames(this._Types) : null; var pathInfo = new ElasticsearchPathInfo <K>() { Index = indices, Type = types, Name = this._Name }; pathInfo.RequestParameters = queryString ?? new K(); pathInfo.RequestParameters.RequestConfiguration(r => this._RequestConfiguration); return(pathInfo); } }