コード例 #1
0
        public void CreateNewIndexAndMappingForNestedArrayOfChild()
        {
            var mappingTestsParent = new MappingTestsParentWithArray
            {
                Calls = 3,
                MappingTestsParentId  = 3,
                MappingTestsItemArray = new[]
                {
                    new MappingTestsChild
                    {
                        Description         = "Hello nested",
                        MappingTestsChildId = 6
                    },
                    new MappingTestsChild
                    {
                        Description         = "Hello nested item in list",
                        MappingTestsChildId = 7
                    }
                }
            };

            using (
                var context = new ElasticsearchContext(ConnectionString,
                                                       new ElasticsearchSerializerConfiguration(_elasticsearchMappingResolver)))
            {
                context.TraceProvider = new ConsoleTraceProvider();
                context.AddUpdateDocument(mappingTestsParent, mappingTestsParent.MappingTestsParentId);
                context.SaveChangesAndInitMappings();

                Thread.Sleep(1500);
                var doc = context.GetDocument <MappingTestsParentWithArray>(mappingTestsParent.MappingTestsParentId);

                Assert.NotNull(doc);
            }
        }
コード例 #2
0
        public void CreateNewIndexAndMappingForNestedArrayOfChild()
        {
            var mappingTestsParent = new MappingTestsParentWithArray
            {
                Calls = 3,
                MappingTestsParentId = 3,
                MappingTestsItemArray = new[]
                {
                    new MappingTestsChild
                    {
                        Description = "Hello nested",
                        MappingTestsChildId = 6
                    },
                    new MappingTestsChild
                    {
                        Description = "Hello nested item in list",
                        MappingTestsChildId = 7
                    }
                }

            };

            using (
                var context = new ElasticsearchContext(ConnectionString,
                    new ElasticsearchSerializerConfiguration(_elasticsearchMappingResolver)))
            {
                context.TraceProvider = new ConsoleTraceProvider();
                context.AddUpdateDocument(mappingTestsParent, mappingTestsParent.MappingTestsParentId);
                context.SaveChangesAndInitMappings();

                Thread.Sleep(1500);
                var doc = context.GetDocument<MappingTestsParentWithArray>(mappingTestsParent.MappingTestsParentId);

                Assert.IsNotNull(doc);
            }
        }