예제 #1
0
        /// <inheritdoc cref="ISearchStore{TDocument}.CreateDocumentType" />
        public void CreateDocumentType()
        {
            if (_log.IsInfoEnabled)
            {
                _log.Info("Create Document type : " + _documentTypeName);
            }

            var client = GetClient();

            var indexDefinition = new RootObjectMapping {
                Properties = new Dictionary <PropertyNameMarker, IElasticType>(),
                Name       = _documentTypeName
            };

            foreach (var field in _definition.Fields)
            {
                IElasticType elasticType = _factory.GetElasticType(field);
                if (elasticType != null)
                {
                    indexDefinition.Properties.Add(field.FieldName, elasticType);
                }
            }

            var res = client.Map <TDocument>(x => x.InitializeUsing(indexDefinition));

            res.CheckStatus("Map");
        }
            private void PrettyPrint(IElasticType type)
            {
                var indent   = new string('-', (this.Depth + 1) * 2);
                var typeName = type.Type != null ? type.Type.Name : "root";
                var name     = type.Name != null ? type.Name.Name : "{default}";

                var s = "{0} {1}: {2}".F(indent, name, typeName);

                this._stringBuilder.AppendLine(s);
            }
예제 #3
0
        public PropertiesDescriptor <T> Custom(IElasticType customMapping)
        {
            customMapping.ThrowIfNull("customMapping");
            if (customMapping.Name.IsConditionless())
            {
                throw new Exception("Could not get field name for custom mapping");
            }


            this.Properties.Add(customMapping.Name, customMapping);
            return(this);
        }
예제 #4
0
파일: Map.cs 프로젝트: Wigren/NEST
 public static Map <T> Type(IElasticType elasticType)
 {
     return(new Map <T>(elasticType));
 }
예제 #5
0
파일: Map.cs 프로젝트: Wigren/NEST
 private void MapType(IElasticType elasticType)
 {
     this.ElasticType = elasticType;
 }
예제 #6
0
파일: Map.cs 프로젝트: Wigren/NEST
 private Map(IElasticType elasticType) : this()
 {
     this.MapType(elasticType);
 }