コード例 #1
0
        public void CreateGeoShapeMultiLineStringMapping()
        {
            var geoShapeMultiLineStringDto = new GeoShapeMultiLineStringDto
            {
                Coordinates = new GeoShapeMultiLineString
                {
                    Coordinates = new List <List <GeoPoint> >
                    {
                        new List <GeoPoint>
                        {
                            new GeoPoint(45, 45),
                            new GeoPoint(46, 45)
                        },
                        new List <GeoPoint>
                        {
                            new GeoPoint(145, 45),
                            new GeoPoint(146, 42)
                        }
                    }
                },
                Id   = "1",
                Name = "test",
            };

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

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

                context.AddUpdateDocument(geoShapeMultiLineStringDto, geoShapeMultiLineStringDto.Id);
                context.SaveChanges();
                Thread.Sleep(1500);
                Assert.AreEqual(1, context.Count <GeoShapeMultiLineStringDto>());
                var result = context.SearchById <GeoShapeMultiLineStringDto>(1);
                Assert.AreEqual(geoShapeMultiLineStringDto.Coordinates.Coordinates.Count, result.Coordinates.Coordinates.Count);
            }
        }
コード例 #2
0
        public void CreateGeoShapeMultiLineStringMapping()
        {
            var geoShapeMultiLineStringDto = new GeoShapeMultiLineStringDto
            {
                Coordinates = new GeoShapeMultiLineString
                {
                    Coordinates = new List<List<GeoPoint>>
                    {
                        new List<GeoPoint>
                        {
                            new GeoPoint(45, 45),
                            new GeoPoint(46, 45)
                        },
                        new List<GeoPoint>
                        {
                            new GeoPoint(145, 45),
                            new GeoPoint(146, 42)
                        }
                    }
                },
                Id = "1",
                Name = "test",
            };

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

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

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