本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例6: TestDefaultContextCountWithNoIndex
public void TestDefaultContextCountWithNoIndex()
{
using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
{
context.Count<SkillTestEntityNoIndex>();
}
}
示例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);
}
}
示例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