コード例 #1
0
        public void CreateGeoShapePointMapping()
        {
            var geoShapePointDto = new GeoShapePointDto
            {
                ShapeCityCoordinates = new GeoShapePoint
                {
                    Coordinates = new GeoPoint(45, 45)
                },
                Id   = "1",
                Name = "test",
            };

            using (var context = new ElasticsearchContext(ConnectionString, new ElasticsearchSerializerConfiguration(_elasticsearchMappingResolver)))
            {
                context.TraceProvider = new ConsoleTraceProvider();
                context.IndexCreate <GeoShapePointDto>();

                Thread.Sleep(1500);
                Assert.IsNotNull(context.IndexExists <GeoShapePointDto>());

                context.AddUpdateDocument(geoShapePointDto, geoShapePointDto.Id);
                context.SaveChanges();
                Thread.Sleep(1500);
                Assert.AreEqual(1, context.Count <GeoShapePointDto>());
                var result = context.SearchById <GeoShapePointDto>(1);
                Assert.AreEqual(geoShapePointDto.ShapeCityCoordinates.Coordinates.Count, result.ShapeCityCoordinates.Coordinates.Count);
            }
        }
コード例 #2
0
        public void CreateGeoShapePointMapping()
        {
            var geoShapePointDto = new GeoShapePointDto
            {
                ShapeCityCoordinates = new GeoShapePoint
                {
                    Coordinates =  new GeoPoint(45, 45)
                },
                Id = "1",
                Name = "test",
            };

            using (var context = new ElasticsearchContext(ConnectionString, new ElasticsearchSerializerConfiguration(_elasticsearchMappingResolver)))
            {
                context.TraceProvider = new ConsoleTraceProvider();
                context.IndexCreate<GeoShapePointDto>();

                Thread.Sleep(1500);
                Assert.IsNotNull(context.IndexExists<GeoShapePointDto>());

                context.AddUpdateDocument(geoShapePointDto, geoShapePointDto.Id);
                context.SaveChanges();
                Thread.Sleep(1500);
                Assert.AreEqual(1, context.Count<GeoShapePointDto>());
                var result = context.SearchById<GeoShapePointDto>(1);
                Assert.AreEqual(geoShapePointDto.ShapeCityCoordinates.Coordinates.Count, result.ShapeCityCoordinates.Coordinates.Count);
            }
        }