public void Execute() { var fieldName = this.ExpressionBuilder.GetFieldName(this.FieldExpression); var formule = ParameterUtil.GetSpatialFormule(fieldName, this.FunctionType, this.CenterPoint, this.Distance); var facetName = ParameterUtil.GetFacetName(this.Excludes, this.AliasName, formule); this._result.Add($"facet.query={facetName}"); if (this.SortType.HasValue) { Checker.IsTrue <UnsupportedFeatureException>(this.SortType.Value == FacetSortType.CountDesc || this.SortType.Value == FacetSortType.IndexDesc); ParameterUtil.GetFacetSort(this.SortType.Value, out string typeName, out string dummy); this._result.Add($"f.{this.AliasName}.facet.sort={typeName}"); } if (this.Minimum.HasValue) { this._result.Add($"f.{this.AliasName}.facet.mincount={this.Minimum.Value}"); } if (this.Limit.HasValue) { this._result.Add($"f.{this.AliasName}.facet.limit={this.Limit.Value}"); } }
public void Execute() { Checker.IsNull(this.Query); Checker.IsTrue <UnsupportedFeatureException>(this.Filter != null); var query = this.Query.Execute(); this._result.Add($"facet.query={ParameterUtil.GetFacetName(this.Excludes, this.AliasName, query)}"); if (this.SortType.HasValue) { Checker.IsTrue <UnsupportedFeatureException>(this.SortType.Value == FacetSortType.CountDesc || this.SortType.Value == FacetSortType.IndexDesc); ParameterUtil.GetFacetSort(this.SortType.Value, out string typeName, out string dummy); this._result.Add($"f.{this.AliasName}.facet.sort={typeName}"); } if (this.Minimum.HasValue) { this._result.Add($"f.{this.AliasName}.facet.mincount={this.Minimum.Value}"); } if (this.Limit.HasValue) { this._result.Add($"f.{this.AliasName}.facet.limit={this.Limit.Value}"); } }
public void Execute() { Checker.IsNull(this.FieldExpression); Checker.IsTrue <UnsupportedFeatureException>(this.Filter != null); var aliasName = this.ExpressionBuilder.GetAliasName(this.FieldExpression); var fieldName = this.ExpressionBuilder.GetFieldName(this.FieldExpression); var facetField = ParameterUtil.GetFacetName(this.Excludes, aliasName, fieldName); this._result.Add($"facet.field={facetField}"); if (this.SortType.HasValue) { Checker.IsTrue <UnsupportedFeatureException>(this.SortType == FacetSortType.CountDesc || this.SortType == FacetSortType.IndexDesc); ParameterUtil.GetFacetSort(this.SortType.Value, out string typeName, out string dummy); this._result.Add($"f.{fieldName}.facet.sort={typeName}"); } if (this.Minimum.HasValue) { this._result.Add($"f.{fieldName}.facet.mincount={this.Minimum.Value}"); } if (this.Limit.HasValue) { this._result.Add($"f.{fieldName}.facet.limit={this.Limit.Value}"); } if (this.MethodType.HasValue) { var methodName = string.Empty; switch (this.MethodType.Value) { case FacetMethodType.UninvertedField: methodName = "fc"; break; case FacetMethodType.DocValues: methodName = "enum"; break; case FacetMethodType.Stream: methodName = "fcs"; break; default: throw new ArgumentOutOfRangeException(nameof(this.MethodType)); } this._result.Add($"f.{fieldName}.facet.method={methodName}"); } if (!string.IsNullOrWhiteSpace(this.Prefix)) { this._result.Add($"f.{fieldName}.facet.prefix={this.Prefix}"); } }
public void Execute() { var array = new List <JProperty> { new JProperty("q", this.Query.Execute()) }; JProperty domain = null; if (this.Excludes?.Any() ?? false) { var excludeValue = new JObject(new JProperty("excludeTags", new JArray(this.Excludes))); domain = new JProperty("domain", excludeValue); } if (this.Filter != null) { var filter = new JProperty("filter", this.Filter.Execute()); domain = domain ?? new JProperty("domain", new JObject()); ((JObject)domain.Value).Add(filter); } if (domain != null) { array.Add(domain); } if (this.Minimum.HasValue) { array.Add(new JProperty("mincount", this.Minimum.Value)); } if (this.Limit.HasValue) { array.Add(new JProperty("limit", this.Limit.Value)); } if (this.SortType.HasValue) { ParameterUtil.GetFacetSort(this.SortType.Value, out string typeName, out string sortName); array.Add(new JProperty("sort", new JObject(new JProperty(typeName, sortName)))); } if (this.Facets?.Any() ?? false) { Parallel.ForEach(this.Facets, item => ((ISearchItemExecution <JObject>)item).Execute()); var subfacets = new JObject(); foreach (var item in this.Facets) { ((ISearchItemExecution <JObject>)item).AddResultInContainer(subfacets); } array.Add((JProperty)subfacets.First); } this._result = new JProperty(this.AliasName, new JObject(new JProperty("query", new JObject(array.ToArray())))); }
public void Execute() { Checker.IsTrue <UnsupportedFeatureException>(this.Filter != null); var fieldName = this.ExpressionBuilder.GetFieldName(this.FieldExpression); var facetName = ParameterUtil.GetFacetName(this.Excludes, this.AliasName, fieldName); this._result.Add($"facet.range={facetName}"); if (!string.IsNullOrWhiteSpace(this.Gap)) { this._result.Add($"f.{fieldName}.facet.range.gap={Uri.EscapeDataString(this.Gap)}"); } if (!string.IsNullOrWhiteSpace(this.Start)) { this._result.Add($"f.{fieldName}.facet.range.start={Uri.EscapeDataString(this.Start)}"); } if (!string.IsNullOrWhiteSpace(this.End)) { this._result.Add($"f.{fieldName}.facet.range.end={Uri.EscapeDataString(this.End)}"); } if (this.CountBefore) { this._result.Add($"f.{fieldName}.facet.range.other=before"); } if (this.CountAfter) { this._result.Add($"f.{fieldName}.facet.range.other=after"); } if (this.HardEnd) { this._result.Add($"f.{fieldName}.facet.range.hardend=true"); } if (this.SortType.HasValue) { Checker.IsTrue <UnsupportedFeatureException>(this.SortType.Value == FacetSortType.CountDesc || this.SortType.Value == FacetSortType.IndexDesc); ParameterUtil.GetFacetSort(this.SortType.Value, out string typeName, out string dummy); this._result.Add($"f.{fieldName}.facet.sort={typeName}"); } if (this.Minimum.HasValue) { this._result.Add($"f.{fieldName}.facet.mincount={this.Minimum.Value}"); } if (this.Limit.HasValue) { this._result.Add($"f.{fieldName}.facet.limit={this.Limit.Value}"); } }
public void Execute() { var formule = ParameterUtil.GetSpatialFormule( this.ExpressionBuilder.GetFieldName(this.FieldExpression), this.FunctionType, this.CenterPoint, this.Distance); var array = new List <JProperty> { new JProperty("q", formule) }; JProperty domain = null; if (this.Excludes?.Any() ?? false) { var excludeValue = new JObject(new JProperty("excludeTags", new JArray(this.Excludes))); domain = new JProperty("domain", excludeValue); } if (this.Filter != null) { var filter = new JProperty("filter", this.Filter.Execute()); domain = domain ?? new JProperty("domain", new JObject()); ((JObject)domain.Value).Add(filter); } if (domain != null) { array.Add(domain); } if (this.Minimum.HasValue) { array.Add(new JProperty("mincount", this.Minimum.Value)); } if (this.SortType.HasValue) { ParameterUtil.GetFacetSort(this.SortType.Value, out string typeName, out string sortName); array.Add(new JProperty("sort", new JObject(new JProperty(typeName, sortName)))); } this._result = new JProperty(this.AliasName, new JObject(new JProperty("query", new JObject(array.ToArray())))); }
public void Execute() { var array = new List <JProperty> { new JProperty("field", this.ExpressionBuilder.GetFieldName(this.FieldExpression)) }; JProperty domain = null; if (this.Excludes?.Any() ?? false) { var excludeValue = new JObject(new JProperty("excludeTags", new JArray(this.Excludes))); domain = new JProperty("domain", excludeValue); } if (this.Filter != null) { var filter = new JProperty("filter", this.Filter.Execute()); domain = domain ?? new JProperty("domain", new JObject()); ((JObject)domain.Value).Add(filter); } if (domain != null) { array.Add(domain); } if (this.Minimum.HasValue) { array.Add(new JProperty("mincount", this.Minimum.Value)); } if (!string.IsNullOrWhiteSpace(this.Gap)) { array.Add(new JProperty("gap", this.Gap)); } if (!string.IsNullOrWhiteSpace(this.Start)) { array.Add(new JProperty("start", this.Start)); } if (!string.IsNullOrWhiteSpace(this.End)) { array.Add(new JProperty("end", this.End)); } if (this.HardEnd) { array.Add(new JProperty("hardend", true)); } if (this.CountBefore || this.CountAfter) { var content = new List <string>(); if (this.CountBefore) { content.Add("before"); } if (this.CountAfter) { content.Add("after"); } array.Add(new JProperty("other", new JArray(content.ToArray()))); } if (this.SortType.HasValue) { ParameterUtil.GetFacetSort(this.SortType.Value, out string typeName, out string sortName); array.Add(new JProperty("sort", new JObject(new JProperty(typeName, sortName)))); } this._result = new JProperty(this.AliasName, new JObject(new JProperty("range", new JObject(array.ToArray())))); }
public void Execute() { var fieldName = this.ExpressionBuilder.GetFieldName(this.FieldExpression); var aliasName = this.ExpressionBuilder.GetAliasName(this.FieldExpression); var array = new List <JProperty> { new JProperty("field", fieldName) }; if (this.Minimum.HasValue) { array.Add(new JProperty("mincount", this.Minimum.Value)); } JProperty domain = null; if (this.Excludes?.Any() ?? false) { var excludeValue = new JObject(new JProperty("excludeTags", new JArray(this.Excludes))); domain = new JProperty("domain", excludeValue); } if (this.Filter != null) { var filter = new JProperty("filter", this.Filter.Execute()); domain = domain ?? new JProperty("domain", new JObject()); ((JObject)domain.Value).Add(filter); } if (this.MethodType.HasValue) { var methodName = string.Empty; switch (this.MethodType.Value) { case FacetMethodType.UninvertedField: methodName = "method:uif"; break; case FacetMethodType.DocValues: methodName = "method:dv"; break; case FacetMethodType.Stream: methodName = "method:stream"; break; } var method = new JProperty("method", methodName); domain = domain ?? new JProperty("domain", new JObject()); ((JObject)domain.Value).Add(method); } if (!string.IsNullOrWhiteSpace(this.Prefix)) { var filter = new JProperty("prefix", this.Prefix); domain = domain ?? new JProperty("domain", new JObject()); ((JObject)domain.Value).Add(filter); } if (domain != null) { array.Add(domain); } if (this.SortType.HasValue) { ParameterUtil.GetFacetSort(this.SortType.Value, out string typeName, out string sortName); array.Add(new JProperty("sort", new JObject(new JProperty(typeName, sortName)))); } if (this.Limit.HasValue) { array.Add(new JProperty("limit", this.Limit)); } if (this.Facets?.Any() ?? false) { Parallel.ForEach(this.Facets, item => ((ISearchItemExecution <JObject>)item).Execute()); var subfacets = new JObject(); foreach (var item in this.Facets) { ((ISearchItemExecution <JObject>)item).AddResultInContainer(subfacets); } array.Add((JProperty)subfacets.First); } this._result = new JProperty(aliasName, new JObject(new JProperty("terms", new JObject(array.ToArray())))); }