public static bool IsDatePropertyType(this IElasticQueryVisitorContext context, string field) { if (String.IsNullOrEmpty(field)) { return(false); } return(context.GetPropertyMapping(field) is IDateProperty); }
public static bool IsPropertyAnalyzed(this IElasticQueryVisitorContext context, string field) { if (String.IsNullOrEmpty(field)) { return(true); } var property = context.GetPropertyMapping(field); if (property == null) { return(false); } return(context.IsPropertyAnalyzed(property)); }
public static string GetNonAnalyzedFieldName(this IElasticQueryVisitorContext context, string field) { if (String.IsNullOrEmpty(field)) { return(field); } var property = context.GetPropertyMapping(field); if (property == null || !context.IsPropertyAnalyzed(property)) { return(field); } var multiFieldProperty = property as ICoreProperty; if (multiFieldProperty?.Fields == null) { return(field); } var nonAnalyzedProperty = multiFieldProperty.Fields.FirstOrDefault(kvp => { if (kvp.Value is IKeywordProperty) { return(true); } if (!context.IsPropertyAnalyzed(kvp.Value)) { return(true); } return(false); }); if (nonAnalyzedProperty.Value != null) { return(field + "." + nonAnalyzedProperty.Key.Name); } return(field); }
public static FieldType GetFieldType(this IElasticQueryVisitorContext context, string field) { if (String.IsNullOrWhiteSpace(field)) { return(FieldType.None); } var mapping = context.GetPropertyMapping(field); if (mapping?.Type == null) { return(FieldType.None); } switch (mapping.Type.Name) { case "geo_point": return(FieldType.GeoPoint); case "geo_shape": return(FieldType.GeoShape); case "attachment": return(FieldType.Attachment); case "ip": return(FieldType.Ip); case "binary": return(FieldType.Binary); case "string": return(FieldType.String); case "keyword": return(FieldType.Keyword); case "text": return(FieldType.Text); case "date": return(FieldType.Date); case "boolean": return(FieldType.Boolean); case "completion": return(FieldType.Completion); case "nested": return(FieldType.Nested); case "object": return(FieldType.Object); case "murmur3": return(FieldType.Murmur3Hash); case "token_count": return(FieldType.TokenCount); case "percolator": return(FieldType.Percolator); case "integer": return(FieldType.Integer); case "long": return(FieldType.Long); case "short": return(FieldType.Short); case "byte": return(FieldType.Byte); case "float": return(FieldType.Float); case "half_float": return(FieldType.HalfFloat); case "scaled_float": return(FieldType.ScaledFloat); case "double": return(FieldType.Double); case "integer_range": return(FieldType.IntegerRange); case "float_range": return(FieldType.FloatRange); case "long_range": return(FieldType.LongRange); case "double_range": return(FieldType.DoubleRange); case "date_range": return(FieldType.DateRange); case "ip_range": return(FieldType.IpRange); default: return(FieldType.None); } }