当前位置: 首页>>代码示例>>C#>>正文


C# ElasticsearchContext.AddUpdateDocument方法代码示例

本文整理汇总了C#中ElasticsearchContext.AddUpdateDocument方法的典型用法代码示例。如果您正苦于以下问题:C# ElasticsearchContext.AddUpdateDocument方法的具体用法?C# ElasticsearchContext.AddUpdateDocument怎么用?C# ElasticsearchContext.AddUpdateDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ElasticsearchContext的用法示例。


在下文中一共展示了ElasticsearchContext.AddUpdateDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            IElasticsearchMappingResolver elasticsearchMappingResolver = new ElasticsearchMappingResolver();
            // You only require a mapping if the default settings are not good enough
            //elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(Skill), new SkillElasticsearchMapping());

            using (var elasticSearchContext = new ElasticsearchContext("http://localhost:9200/", elasticsearchMappingResolver))
            {
                elasticSearchContext.TraceProvider = new TraceProvider("tracingExample");
                elasticSearchContext.AddUpdateDocument(TestData.SkillEf, TestData.SkillEf.Id);
                elasticSearchContext.AddUpdateDocument(TestData.SkillOrm, TestData.SkillOrm.Id);
                elasticSearchContext.AddUpdateDocument(TestData.SkillSQLServer, TestData.SkillSQLServer.Id);
                elasticSearchContext.AddUpdateDocument(TestData.SkillGermanWithFunnyLetters, TestData.SkillGermanWithFunnyLetters.Id);
                elasticSearchContext.AddUpdateDocument(TestData.SkillLevel, TestData.SkillLevel.Id);

                var addEntitiesResult = elasticSearchContext.SaveChanges();

                Console.WriteLine(addEntitiesResult.PayloadResult);
                Console.WriteLine(addEntitiesResult.Status);
                Console.WriteLine(addEntitiesResult.Description);
            }

            using (var elasticSearchContext = new ElasticsearchContext("http://localhost:9200/", elasticsearchMappingResolver))
            {
                elasticSearchContext.TraceProvider = new TraceProvider("tracingExample");
                // get a entity and update it, then delete an entity
                Skill singleEntityWithId = elasticSearchContext.GetDocument<Skill>("11");
                singleEntityWithId.Updated = DateTime.UtcNow;
                elasticSearchContext.AddUpdateDocument(TestData.SkillOrm, TestData.SkillOrm.Id);
                elasticSearchContext.DeleteDocument<Skill>(TestData.SkillEf.Id);
                elasticSearchContext.SaveChanges();

                elasticSearchContext.AddUpdateDocument(TestData.SkillEf, TestData.SkillEf.Id);
                var nextResult = elasticSearchContext.SaveChanges();

                Console.WriteLine(nextResult.PayloadResult);
                Console.WriteLine(nextResult.Status);
                Console.WriteLine(nextResult.Description);
            }

            using (var elasticSearchContext = new ElasticsearchContext("http://localhost:9200/", elasticsearchMappingResolver))
            {
                elasticSearchContext.TraceProvider = new TraceProvider("tracingExample");
                // deleting indexes are usually not required...
                elasticSearchContext.AllowDeleteForIndex = true;
                var result = elasticSearchContext.DeleteIndexAsync<SkillLevel>();
                result.Wait();
                var result1 = elasticSearchContext.DeleteIndexAsync<Skill>();
                result1.Wait();
                //var result = elasticSearchContext.DeleteIndex<Skill>();
                elasticSearchContext.SaveChanges();
                //Console.WriteLine(result.Result.PayloadResult);
                //Console.WriteLine(result.Result.Status);
                //Console.WriteLine(result.Result.Description);
                //Console.ReadLine();
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:57,代码来源:Program.cs

示例2: CreateAliasForIndex2

        public void CreateAliasForIndex2()
        {
            var indexAliasDtoTest = new IndexAliasDtoTest { Id = 1, Description = "Test index for aliases" };

            var aliasParameters = new AliasParameters
            {
                Actions = new List<AliasBaseParameters>
                {
                    new AliasAddParameters("test2", "indexaliasdtotests"),
                    new AliasAddParameters("test3", "indexaliasdtotests")
                }
            };

            using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
            {
                context.AddUpdateDocument(indexAliasDtoTest, indexAliasDtoTest.Id);
                context.SaveChanges();

                var result = context.Alias(aliasParameters.ToString());
                Assert.IsTrue(result);

                Assert.IsTrue(context.AliasExists("test2"));
                Assert.IsTrue(context.AliasExists("test3"));

            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:26,代码来源:AliasElasticsearchCrudTests.cs

示例3: CreateGeoShapeCircleMapping

        public void CreateGeoShapeCircleMapping()
        {
            var geoShapeCircleDto = new GeoShapeCircleDto
            {
                CircleTest = new GeoShapeCircle
                {
                    Coordinates = new GeoPoint(45, 45),
                    Radius="100m"
                },
                Id = "1",
                Name = "test",
            };

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

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

                context.AddUpdateDocument(geoShapeCircleDto, geoShapeCircleDto.Id);
                context.SaveChanges();
                Thread.Sleep(1500);
                Assert.AreEqual(1, context.Count<GeoShapeCircleDto>());
                var result = context.SearchById<GeoShapeCircleDto>(1);
                Assert.AreEqual(geoShapeCircleDto.CircleTest.Coordinates.Count, result.CircleTest.Coordinates.Count);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:29,代码来源:GeoPointAndGeoShapeTests.cs

示例4: Setup

        public void Setup()
        {
            var doc1 = new SearchTest
            {
                Id = 1,
                Details = "This is the details of the document, very interesting",
                Name = "one",
                CircleTest = new GeoShapeCircle { Radius = "100m", Coordinates = new GeoPoint(45, 45) },
                Location = new GeoPoint(45, 45),
                Lift = 2.9,
                DateOfDetails = DateTime.UtcNow.AddDays(-20)
            };

            var doc2 = new SearchTest
            {
                Id = 2,
                Details = "Details of the document two, leave it alone",
                Name = "two",
                CircleTest = new GeoShapeCircle { Radius = "50m", Coordinates = new GeoPoint(46, 45) },
                Location = new GeoPoint(46, 45),
                Lift = 2.5,
                DateOfDetails = DateTime.UtcNow.AddDays(-209)
            };
            var doc3 = new SearchTest
            {
                Id = 3,
                Details = "This data is different",
                Name = "three",
                CircleTest = new GeoShapeCircle { Radius = "80m", Coordinates = new GeoPoint(37, 42) },
                Location = new GeoPoint(37, 42),
                Lift = 2.1,
                DateOfDetails = DateTime.UtcNow.AddDays(-34)
            };
            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                context.IndexCreate<SearchTest>();
                Thread.Sleep(1200);
                context.AddUpdateDocument(doc1, doc1.Id);
                context.AddUpdateDocument(doc2, doc2.Id);
                context.AddUpdateDocument(doc3, doc3.Id);
                context.SaveChanges();
                Thread.Sleep(1200);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:44,代码来源:SetupSearch.cs

示例5: SaveToElasticsearchStateProvinceIfitDoesNotExist

		public void SaveToElasticsearchStateProvinceIfitDoesNotExist()
		{
			IElasticsearchMappingResolver elasticsearchMappingResolver = new ElasticsearchMappingResolver();
			using (var elasticSearchContext = new ElasticsearchContext("http://localhost:9200/", new ElasticsearchSerializerConfiguration(elasticsearchMappingResolver, true, true)))
			{
				if (!elasticSearchContext.IndexTypeExists<StateProvince>())
				{
					elasticSearchContext.TraceProvider = new ConsoleTraceProvider();
					using (var databaseEfModel = new EfModel())
					{
						int pointer = 0;
						const int interval = 20;
						bool firstRun = true;
						int length = databaseEfModel.StateProvince.Count();

						while (pointer < length)
						{
							_stopwatch.Start();
							var collection =
								databaseEfModel.StateProvince.OrderBy(t => t.StateProvinceID)
									.Skip(pointer)
									.Take(interval)
									.ToList<StateProvince>();
							_stopwatch.Stop();
							Console.WriteLine("Time taken for select {0} Address: {1}", interval, _stopwatch.Elapsed);
							_stopwatch.Reset();

							_stopwatch.Start();
							foreach (var item in collection)
							{
								var ee = item.CountryRegion.Name;
								elasticSearchContext.AddUpdateDocument(item, item.StateProvinceID);
							}

							if (firstRun)
							{
								elasticSearchContext.SaveChangesAndInitMappings();
								firstRun = false;
							}
							else
							{
								elasticSearchContext.SaveChanges();
							}

							_stopwatch.Stop();
							Console.WriteLine("Time taken to insert {0} Address documents: {1}", interval, _stopwatch.Elapsed);
							_stopwatch.Reset();
							pointer = pointer + interval;
							Console.WriteLine("Transferred: {0} items", pointer);
						}
					}
				}
			}
		}
开发者ID:emretiryaki,项目名称:WebSearchWithElasticsearchEntityFrameworkAsPrimary,代码行数:54,代码来源:InitializeSearchEngine.cs

示例6: CreateAliasForIndex

        public void CreateAliasForIndex()
        {
            var indexAliasDtoTest = new IndexAliasDtoTest {Id = 1, Description = "Test index for aliases"};

            using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
            {
                context.AddUpdateDocument(indexAliasDtoTest,  indexAliasDtoTest.Id);
                context.SaveChanges();

                var result = context.AliasCreateForIndex("test", "indexaliasdtotests");
                Assert.IsTrue(result);

                Thread.Sleep(1200);

                GetResult resultGet = context.Get(new Uri("http://localhost:9200/_alias/test"));
                Console.WriteLine(resultGet);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:18,代码来源:AliasElasticsearchCrudTests.cs

示例7: TestCreateCompletelyNewIndexExpectException

        public void TestCreateCompletelyNewIndexExpectException()
        {
            var parentDocument = GetParentDocumentEx();

            _elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(ChildDocumentLevelOneEx),
                new ElasticsearchMappingChildDocumentForParentEx());
            _elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(ChildDocumentLevelTwoEx),
                new ElasticsearchMappingChildDocumentForParentEx());

            using (var context = new ElasticsearchContext(ConnectionString,new ElasticsearchSerializerConfiguration(_elasticsearchMappingResolver, true, true)))
            {
                context.TraceProvider = new ConsoleTraceProvider();
                context.AddUpdateDocument(parentDocument, parentDocument.Id);

                // Save to Elasticsearch
                context.SaveChangesAndInitMappings();
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:18,代码来源:DocumentsWithChildDocumentsTestNotAllowed.cs

示例8: TestDefaultContextParentNestedIntArray

        public void TestDefaultContextParentNestedIntArray()
        {
            using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
            {
                context.TraceProvider = new ConsoleTraceProvider();
                var skillWithIntArray = new SkillWithIntArray
                {
                    MyIntArray = new[] { 2, 4, 6, 99, 7 },
                    BlahBlah = "test3 with int array",
                    Id = 2
                };
                context.AddUpdateDocument(skillWithIntArray, skillWithIntArray.Id);

                // Save to Elasticsearch
                var ret = context.SaveChanges();
                Assert.AreEqual(ret.Status, HttpStatusCode.OK);

                var returned = context.GetDocument<SkillWithIntArray>(2);
                Assert.AreEqual(skillWithIntArray.MyIntArray[2], returned.MyIntArray[2]);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:21,代码来源:OneToNNestedElasticsearchCrudTests.cs

示例9: SearchAggNestedBucketAggregationWithNoHits

        public void SearchAggNestedBucketAggregationWithNoHits()
        {
            var testSkillParentObject = new NestedCollectionTest
            {
                CreatedSkillParent = DateTime.UtcNow,
                UpdatedSkillParent = DateTime.UtcNow,
                DescriptionSkillParent = "A test entity description",
                Id = 8,
                NameSkillParent = "cool",
                SkillChildren = new Collection<SkillChild> { _entitiesForSkillChild[0], _entitiesForSkillChild[1], _entitiesForSkillChild[2] }
            };

            using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
            {
                context.IndexCreate<NestedCollectionTest>();
                Thread.Sleep(1200);
                context.AddUpdateDocument(testSkillParentObject, testSkillParentObject.Id);
                var ret = context.SaveChanges();
                Assert.AreEqual(ret.Status, HttpStatusCode.OK);
            }

            Thread.Sleep(1200);

            var search = new Search
            {
                Aggs = new List<IAggs>
                {
                    new NestedBucketAggregation("nestedagg", "skillchildren")
                }
            };

            using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
            {
                Assert.IsTrue(context.IndexTypeExists<NestedCollectionTest>());
                var items = context.Search<NestedCollectionTest>(search, new SearchUrlParameters { SeachType = SeachType.count });
                var aggResult = items.PayloadResult.Aggregations.GetComplexValue<NestedBucketAggregationsResult>("nestedagg");
                Assert.AreEqual(3, aggResult.DocCount);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:39,代码来源:NestedArraysTestsWithFiltersAndQueriesAndAggregations.cs

示例10: SaveToElasticsearchAddress

        public void SaveToElasticsearchAddress()
        {
            IElasticsearchMappingResolver ElasticsearchMappingResolver = new ElasticsearchMappingResolver();
            using (var ElasticsearchContext = new ElasticsearchContext("http://localhost:9200/", ElasticsearchMappingResolver))
            {
                //ElasticsearchContext.TraceProvider = new ConsoleTraceProvider();
                using (var modelPerson = new ModelPerson())
                {
                    int pointer = 0;
                    const int interval = 100;
                    int length = modelPerson.Address.Count();

                    while (pointer < length)
                    {
                        stopwatch.Start();
                        var collection = modelPerson.Address.OrderBy(t => t.AddressID).Skip(pointer).Take(interval).ToList<Address>();
                        stopwatch.Stop();
                        Console.WriteLine("Time taken for select {0} AddressID: {1}", interval, stopwatch.Elapsed);
                        stopwatch.Reset();

                        foreach (var item in collection)
                        {
                            ElasticsearchContext.AddUpdateDocument(item, item.AddressID);
                            string t = "yes";
                        }

                        stopwatch.Start();
                        ElasticsearchContext.SaveChanges();
                        stopwatch.Stop();
                        Console.WriteLine("Time taken to insert {0} AddressID documents: {1}", interval, stopwatch.Elapsed);
                        stopwatch.Reset();
                        pointer = pointer + interval;
                        Console.WriteLine("Transferred: {0} items", pointer);
                    }
                }
            }
        }
开发者ID:Gwill,项目名称:DataTransferSQLWithEntityFrameworkToElasticsearch,代码行数:37,代码来源:Repo.cs

示例11: CreateNewIndexAndMappingForNestedArrayOfChild

        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);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:36,代码来源:MappingTests.cs

示例12: RemoveAliasthatDoesNotExistForIndex

        public void RemoveAliasthatDoesNotExistForIndex()
        {
            var indexAliasDtoTest = new IndexAliasDtoTest { Id = 1, Description = "Test index for aliases" };

            using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
            {
                context.AddUpdateDocument(indexAliasDtoTest, indexAliasDtoTest.Id);
                context.SaveChanges();

                var result = context.AliasRemoveForIndex("tefdfdfdsfst", "indexaliasdtotests");
                Assert.IsTrue(result);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:13,代码来源:AliasElasticsearchCrudTests.cs

示例13: Setup

        public void Setup()
        {
            var doc1 = new SearchAggTest
            {
                Id = 1,
                Details = "This is the details of the document, very interesting",
                Name = "one",
                CircleTest = new GeoShapeCircle { Radius = "100m", Coordinates = new GeoPoint(45, 45) },
                Location = new GeoPoint(45, 45),
                Lift = 2.9,
                LengthOfSomeThing = 345.4,
                DateOfDetails = DateTime.UtcNow.AddDays(-20)
            };

            var doc2 = new SearchAggTest
            {
                Id = 2,
                Details = "Details of the document two, leave it alone",
                Name = "two",
                CircleTest = new GeoShapeCircle { Radius = "50m", Coordinates = new GeoPoint(46, 45) },
                Location = new GeoPoint(46, 45),
                Lift = 2.5,
                LengthOfSomeThing = 289.0,
                DateOfDetails = DateTime.UtcNow.AddDays(-209)
            };
            var doc3 = new SearchAggTest
            {
                Id = 3,
                Details = "This data is different",
                Name = "three",
                CircleTest = new GeoShapeCircle { Radius = "80m", Coordinates = new GeoPoint(37, 42) },
                Location = new GeoPoint(37, 42),
                Lift = 2.1,
                LengthOfSomeThing = 324.0,
                DateOfDetails = DateTime.UtcNow.AddDays(-34)
            };

            var doc4 = new SearchAggTest
            {
                Id = 4,
                Details = "This data is different from the last one",
                Name = "four",
                CircleTest = new GeoShapeCircle { Radius = "800m", Coordinates = new GeoPoint(34, 42) },
                Location = new GeoPoint(37, 42),
                Lift = 2.1,
                LengthOfSomeThing = 625.0,
                DateOfDetails = DateTime.UtcNow.AddDays(-37)
            };

            var doc5 = new SearchAggTest
            {
                Id = 5,
                Details = "five stuff from the road",
                Name = "five",
                CircleTest = new GeoShapeCircle { Radius = "300m", Coordinates = new GeoPoint(34, 41) },
                Location = new GeoPoint(37, 42),
                Lift = 1.7,
                LengthOfSomeThing = 605.0,
                DateOfDetails = DateTime.UtcNow.AddDays(-47)
            };

            var doc6 = new SearchAggTest
            {
                Id = 6,
                Details = "a lot of things happening now",
                Name = "six",
                CircleTest = new GeoShapeCircle { Radius = "3000m", Coordinates = new GeoPoint(35, 41) },
                Location = new GeoPoint(32, 44),
                Lift = 2.9,
                LengthOfSomeThing = 128.0,
                DateOfDetails = DateTime.UtcNow.AddDays(-46)
            };

            var doc7 = new SearchAggTest
            {
                Id = 7,
                Details = "we made it to seven",
                Name = "seven",
                CircleTest = new GeoShapeCircle { Radius = "4000m", Coordinates = new GeoPoint(35, 40) },
                Location = new GeoPoint(34, 43),
                Lift = 2.1,
                LengthOfSomeThing = 81,
                DateOfDetails = DateTime.UtcNow.AddDays(-46)
            };
            using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
            {
                context.IndexCreate<SearchAggTest>();
                Thread.Sleep(1200);
                context.AddUpdateDocument(doc1, doc1.Id);
                context.AddUpdateDocument(doc2, doc2.Id);
                context.AddUpdateDocument(doc3, doc3.Id);
                context.AddUpdateDocument(doc4, doc4.Id);
                context.AddUpdateDocument(doc5, doc5.Id);
                context.AddUpdateDocument(doc6, doc6.Id);
                context.AddUpdateDocument(doc7, doc7.Id);
                context.SaveChanges();
                Thread.Sleep(1200);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:99,代码来源:SetupSearchAgg.cs

示例14: CreateNewIndexAndMappingWithAnalyzer

        public void CreateNewIndexAndMappingWithAnalyzer()
        {
            var indexDefinition = new IndexDefinition { IndexSettings = { NumberOfShards = 3, NumberOfReplicas = 1 } };
            indexDefinition.Mapping.All.Enabled = false;
            indexDefinition.Mapping.Analyzer = new MappingAnalyzer { Path = "myanalyzer" };

            var mappingTypeAll = new MappingTypeAnalyzerTest
            {
                Id = 1,
                SomeText = "I think search engines are great",
                MyAnalyzer= "whitespace"

            };

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

                context.AddUpdateDocument(mappingTypeAll, mappingTypeAll.Id);
                context.SaveChanges();

                Thread.Sleep(1500);

                var doc = context.Search<MappingTypeAnalyzerTest>(BuildSearchById(1));
                Assert.GreaterOrEqual(doc.PayloadResult.Hits.HitsResult.First().Id.ToString(), "1");
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:30,代码来源:MappingTypeTests.cs

示例15: TestDefaultContextParentWithACollectionOfThreeChildObjectsOfNestedType

        public void TestDefaultContextParentWithACollectionOfThreeChildObjectsOfNestedType()
        {
            var testSkillParentObject = new NestedCollectionTest
            {
                CreatedSkillParent = DateTime.UtcNow,
                UpdatedSkillParent = DateTime.UtcNow,
                DescriptionSkillParent = "A test entity description",
                Id = 8,
                NameSkillParent = "cool",
                SkillChildren = new Collection<SkillChild> { _entitiesForSkillChild[0], _entitiesForSkillChild[1], _entitiesForSkillChild[2] }
            };

            using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
            {
                context.TraceProvider = new ConsoleTraceProvider();
                context.IndexCreate<NestedCollectionTest>();
                Thread.Sleep(1200);
                context.AddUpdateDocument(testSkillParentObject, testSkillParentObject.Id);

                // Save to Elasticsearch
                var ret = context.SaveChanges();
                Assert.AreEqual(ret.Status, HttpStatusCode.OK);

                var roundTripResult = context.GetDocument<NestedCollectionTest>(testSkillParentObject.Id);
                Assert.AreEqual(roundTripResult.DescriptionSkillParent, testSkillParentObject.DescriptionSkillParent);
                Assert.AreEqual(roundTripResult.SkillChildren.First().DescriptionSkillChild, testSkillParentObject.SkillChildren.First().DescriptionSkillChild);
                Assert.AreEqual(roundTripResult.SkillChildren.ToList()[1].DescriptionSkillChild, testSkillParentObject.SkillChildren.ToList()[1].DescriptionSkillChild);
                Assert.AreEqual(roundTripResult.SkillChildren.ToList()[1].DescriptionSkillChild, testSkillParentObject.SkillChildren.ToList()[1].DescriptionSkillChild);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:30,代码来源:NestedArraysTestsWithFiltersAndQueriesAndAggregations.cs


注:本文中的ElasticsearchContext.AddUpdateDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。