Esempio n. 1
0
        internal Schema MapObjectToSchema(Type t)
        {
            var schema        = new Schema();
            var typeProperies = t.GetProperties()
                                .Select(prop => new { prop.Name, Code = Type.GetTypeCode(prop.PropertyType) });

            foreach (var prop in typeProperies)
            {
                switch (prop.Code)
                {
                case TypeCode.Int16:
                case TypeCode.Int32:
                case TypeCode.Int64:
                case TypeCode.Decimal:
                case TypeCode.Double:
                case TypeCode.Single:
                case TypeCode.SByte:
                case TypeCode.Byte:
                    schema.AddNumericField(prop.Name);
                    break;

                default:
                    schema.AddTextField(prop.Name.ToLower());
                    break;
                }
            }
            return(schema);
        }
Esempio n. 2
0
        public Schema BuildSchemaForSearch(SchemaHelperModel schemaModel)
        {
            var currentSchema = new Schema();

            foreach (var item in schemaModel.SearchFields)
            {
                currentSchema.AddField(item);
            }
            foreach (var item in schemaModel.TextFields)
            {
                currentSchema.AddSortableTextField(item.FIeldName, item.Weignt);
            }
            foreach (var item in schemaModel.NumericFieldName)
            {
                currentSchema.AddNumericField(item);
            }
            foreach (var item in schemaModel.TagFilterName)
            {
                currentSchema.AddTagField(item);
            }
            foreach (var item in schemaModel.GeoFilterName)
            {
                currentSchema.AddGeoField(item);
            }

            return(currentSchema);
        }