コード例 #1
0
        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);
        }
コード例 #2
0
        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));
        }