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


C# ElasticsearchContext.Count方法代码示例

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


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

示例1: 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

示例2: GlobalElasticsearchMappingCountTest

 public void GlobalElasticsearchMappingCountTest()
 {
     // You require this for a global search, it is in the setup fixture
     //_elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(object), new GlobalElasticsearchMapping());
     using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
     {
         var count = context.Count<object>();
         Assert.GreaterOrEqual(count, 3);
     }
 }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:10,代码来源:GlobalApiTestsSearchCountTests.cs

示例3: TestDocumentCountChildDocumentWithQuery

        public void TestDocumentCountChildDocumentWithQuery()
        {
            using (var context = new ElasticsearchContext(ConnectionString, new ElasticsearchSerializerConfiguration(_elasticsearchMappingResolver, SaveChildObjectsAsWellAsParent, ProcessChildDocumentsAsSeparateChildIndex)))
            {
                context.TraceProvider = new ConsoleTraceProvider();

                var found = context.Count<ChildDocumentLevelTwo>(BuildSearchForChildDocumentsWithIdAndParentType(22, "childdocumentlevelone"));
                Assert.Greater(found, 0);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:10,代码来源:OneToNEntitiesSaveWithChildDocumentsTest.cs

示例4: CreateGeoShapePolygonMapping

        public void CreateGeoShapePolygonMapping()
        {
            var geoShapePolygonDto = new GeoShapePolygonDto
            {
                Coordinates = new GeoShapePolygon
                {
                    Coordinates = new List<List<GeoPoint>>
                    {
                        // [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]
                        new List<GeoPoint>
                        {
                            new GeoPoint(100, 0),
                            new GeoPoint(101, 0),
                            new GeoPoint(101, 1),
                            new GeoPoint(100, 1),
                            new GeoPoint(100, 0)
                        },
                        //  [ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
                        new List<GeoPoint>
                        {
                            new GeoPoint(100.2, 0.2),
                            new GeoPoint(100.8, 0.2),
                            new GeoPoint(100.8, 0.8),
                            new GeoPoint(100.2, 0.8),
                            new GeoPoint(100.2, 0.2)
                        }
                    }
                },
                Id = "1",
                Name = "test",
            };

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

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

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

示例5: TestDefaultContextDeleteByQuerySingleDocumentWithId

        public void TestDefaultContextDeleteByQuerySingleDocumentWithId()
        {
            const int documentId = 153;
            string deleteJson = "{\"query\": { \"term\": { \"_id\": \"" + documentId + "\" }}}";
            using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
            {
                context.TraceProvider = new ConsoleTraceProvider();
                for (int i = 150; i < 160; i++)
                {
                    context.AddUpdateDocument(_entitiesForTests[i-150], i);
                }
                // Save to Elasticsearch
                var ret = context.SaveChanges();

                // Wait for Elasticsearch to update
                long foundBefore = 0;

                Task.Run(() =>
                {
                    while (true)
                    {
                        Thread.Sleep(300);
                        foundBefore = context.Count<SkillTestEntity>();
                        if (foundBefore > 9)
                        {
                            _resetEvent.Set();
                        }
                    }
                });

                // allow elasticsearch time to update...
                WaitForDataOrFail();

                Assert.AreEqual(ret.Status, HttpStatusCode.OK);
                context.DeleteByQuery<SkillTestEntity>(deleteJson);

                // Clear thecache so count or get returns the latest value
                context.IndexClearCache<SkillTestEntity>();
                long foundAfter = context.Count<SkillTestEntity>();

                Console.WriteLine("found before {0}, after {1}", foundBefore, foundAfter);
                Assert.Greater(foundBefore, foundAfter);
                context.GetDocument<SkillTestEntity>(documentId);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:45,代码来源:DefaultElasticsearchCRUDTests.cs

示例6: TestDefaultContextCountWithNoIndex

 public void TestDefaultContextCountWithNoIndex()
 {
     using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
     {
          context.Count<SkillTestEntityNoIndex>();
     }
 }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:7,代码来源:DefaultElasticsearchCRUDTests.cs

示例7: TestDefaultContextCount

        public void TestDefaultContextCount()
        {
            using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
            {
                context.TraceProvider = new ConsoleTraceProvider();
                for (int i = 0; i < 7; i++)
                {
                    context.AddUpdateDocument(_entitiesForTests[i], i);
                }

                // Save to Elasticsearch
                var ret = context.SaveChanges();
                Assert.AreEqual(ret.Status, HttpStatusCode.OK);
                long found = 0;
                Task.Run(() =>
                {
                    while (true)
                    {
                        Thread.Sleep(300);
                        found = context.Count<SkillTestEntity>();
                        if (found == 7)
                        {
                            _resetEvent.Set();
                        }
                    }
                });

                // allow elasticsearch time to update...
                WaitForDataOrFail();

                Assert.AreEqual(7, found);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:33,代码来源:DefaultElasticsearchCRUDTests.cs

示例8: TestDocumentCountChildDocument

        public void TestDocumentCountChildDocument()
        {
            using (var context = new ElasticsearchContext(ConnectionString, new ElasticsearchSerializerConfiguration(_elasticsearchMappingResolver, SaveChildObjectsAsWellAsParent, ProcessChildDocumentsAsSeparateChildIndex, UserDefinedRouting)))
            {
                context.TraceProvider = new ConsoleTraceProvider();

                var found = context.Count<ChildDocumentLevelTwoUserDefinedRouting>();
                Assert.Greater(found,0);
            }
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:10,代码来源:OneToNEntitiesSaveWithChildDocumentsTestWithRouting.cs


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