本文整理汇总了C#中ElasticsearchContext.IndexExists方法的典型用法代码示例。如果您正苦于以下问题:C# ElasticsearchContext.IndexExists方法的具体用法?C# ElasticsearchContext.IndexExists怎么用?C# ElasticsearchContext.IndexExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElasticsearchContext
的用法示例。
在下文中一共展示了ElasticsearchContext.IndexExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FixtureTearDown
public void FixtureTearDown()
{
using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
{
context.AllowDeleteForIndex = true;
if (context.IndexExists<IndexOne>())
{
context.DeleteIndex<IndexOne>();
}
if (context.IndexExists<IndexTwo>())
{
var entityResult2 = context.DeleteIndexAsync<IndexTwo>();
entityResult2.Wait();
}
}
}
示例2: 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);
}
}
示例3: CreateNewIndexAndMappingWithSimpleNullListAndNullArrayList
public void CreateNewIndexAndMappingWithSimpleNullListAndNullArrayList()
{
using ( var context = new ElasticsearchContext(ConnectionString, new ElasticsearchSerializerConfiguration(_elasticsearchMappingResolver)))
{
context.TraceProvider = new ConsoleTraceProvider();
context.IndexCreate<MappingTestsParent>();
Thread.Sleep(1500);
var result = context.IndexExists<MappingTestsParent>();
Assert.IsTrue(result);
}
}
示例4: FixtureTearDown
public void FixtureTearDown()
{
using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
{
if (context.IndexExists<MappingChildParentRoutingTestsLevel1>())
{
context.AllowDeleteForIndex = true;
context.DeleteIndex<MappingChildParentRoutingTestsLevel1>();
}
if (context.IndexExists<ListMappingChildParentRoutingTestsLevel1>())
{
context.AllowDeleteForIndex = true;
context.DeleteIndex<ListMappingChildParentRoutingTestsLevel1>();
}
}
}
示例5: FixtureTearDown
public void FixtureTearDown()
{
using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
{
context.AllowDeleteForIndex = true;
if (context.IndexExists<MappingTypeAllTest>())
{
context.DeleteIndex<MappingTypeAllTest>();
}
if (context.IndexExists<MappingTypeSourceTest>())
{
context.DeleteIndex<MappingTypeSourceTest>();
}
if (context.IndexExists<MappingTypeAnalyzerTest>())
{
context.DeleteIndex<MappingTypeAnalyzerTest>();
}
}
}
示例6: TearDownFixture
public void TearDownFixture()
{
using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
{
context.AllowDeleteForIndex = true;
if (context.IndexExists<FastestAnimal>())
{
var entityResult1 = context.DeleteIndexAsync<FastestAnimal>();
entityResult1.Wait();
}
if (context.IndexExists<FastestAnimalPostings>())
{
var entityResult2 = context.DeleteIndexAsync<FastestAnimalPostings>();
entityResult2.Wait();
}
if (context.IndexExists<FastestAnimalFastVectorHighlighter>())
{
var entityResult3 = context.DeleteIndexAsync<FastestAnimalFastVectorHighlighter>();
entityResult3.Wait();
}
}
}
示例7: TestIndexExistsForSpecialMapping
public void TestIndexExistsForSpecialMapping()
{
using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
{
context.TraceProvider = new ConsoleTraceProvider();
var found = context.IndexExists<ExistsDtoForTestsTypeNot>();
Assert.IsTrue(found);
}
}
示例8: TestIndexDoesNotExist
public void TestIndexDoesNotExist()
{
using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
{
context.TraceProvider = new ConsoleTraceProvider();
var found = context.IndexExists<ExistsDtoForTestsIndexNot>();
Assert.IsFalse(found);
}
}
示例9: CreateNewIndexAndMappingWithSimpleNullListAndNullArrayListAndAlias
public void CreateNewIndexAndMappingWithSimpleNullListAndNullArrayListAndAlias()
{
using (var context = new ElasticsearchContext(ConnectionString, new ElasticsearchSerializerConfiguration(_elasticsearchMappingResolver)))
{
context.TraceProvider = new ConsoleTraceProvider();
context.IndexCreate<AliasCreateIndexOne>(
new IndexDefinition
{
IndexAliases = new IndexAliases
{
Aliases = new List<IndexAlias>
{
new IndexAlias("testnew"), new IndexAlias("testnewroute")
{
Routing = "ddd"
}
}
}
});
Thread.Sleep(1500);
var result = context.IndexExists<AliasCreateIndexOne>();
Assert.IsTrue(result);
}
}
示例10: CreateNewIndexAndMappingWithSimpleNullListAndNullArrayListAndAliasAndWarmer
public void CreateNewIndexAndMappingWithSimpleNullListAndNullArrayListAndAliasAndWarmer()
{
using (var context = new ElasticsearchContext(ConnectionString, new ElasticsearchSerializerConfiguration(_elasticsearchMappingResolver)))
{
context.TraceProvider = new ConsoleTraceProvider();
context.IndexCreate<AliasCreateIndexOne>(
new IndexDefinition
{
IndexAliases = new IndexAliases
{
Aliases = new List<IndexAlias>
{
new IndexAlias("testnew"), new IndexAlias("testnewroute")
{
Routing = "ddd"
}
}
},
IndexWarmers = new IndexWarmers
{
Warmers = new List<IndexWarmer>
{
new IndexWarmer("warmer_one")
{
Query= new Query(new MatchAllQuery()),
Aggs = new List<IAggs>
{
new SumMetricAggregation("sum", "id")
}
}
}
}
});
Thread.Sleep(1500);
var result = context.IndexExists<AliasCreateIndexOne>();
Assert.IsTrue(result);
}
}
示例11: 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);
}
}
示例12: UpdateIndexSettingsGlobal
public void UpdateIndexSettingsGlobal()
{
using (var context = new ElasticsearchContext(ConnectionString, new ElasticsearchMappingResolver()))
{
if (!context.IndexExists<MappingTestsParent>())
{
context.IndexCreate<MappingTestsParent>();
}
context.TraceProvider = new ConsoleTraceProvider();
var result = context.IndexUpdateSettings(new IndexUpdateSettings { NumberOfReplicas = 1 });
context.AllowDeleteForIndex = true;
context.DeleteIndex<MappingTestsParent>();
Assert.AreEqual("completed", result.PayloadResult);
}
}
示例13: UpdateIndexSettingsClosedIndex
public void UpdateIndexSettingsClosedIndex()
{
const string index = "newindextestmappingtwostep";
IElasticsearchMappingResolver elasticsearchMappingResolver;
var mappingTestsParent = SetupIndexMappingTests(index, out elasticsearchMappingResolver);
using (var context = new ElasticsearchContext(ConnectionString, new ElasticsearchSerializerConfiguration(elasticsearchMappingResolver)))
{
context.TraceProvider = new ConsoleTraceProvider();
context.IndexCreate(index, new IndexSettings { BlocksWrite = true, NumberOfShards = 7 });
context.IndexClose(index);
context.IndexUpdateSettings(new IndexUpdateSettings { NumberOfReplicas = 2 }, index);
context.IndexOpen(index);
Thread.Sleep(1500);
Assert.IsTrue(context.IndexExists<MappingTestsParent>());
if (context.IndexExists<MappingTestsParent>())
{
context.AllowDeleteForIndex = true;
context.DeleteIndex<MappingTestsParent>();
}
}
}
示例14: FixtureTearDown
public void FixtureTearDown()
{
using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
{
if (context.IndexExists<MappingTestsParent>())
{
context.AllowDeleteForIndex = true;
context.DeleteIndex<MappingTestsParent>();
}
if (context.IndexExists<MappingTestsParentWithList>())
{
context.AllowDeleteForIndex = true;
var entityResult2 = context.DeleteIndexAsync<MappingTestsParentWithList>();
entityResult2.Wait();
}
if (context.IndexExists<MappingTestsParentWithArray>())
{
context.AllowDeleteForIndex = true;
var entityResult3 = context.DeleteIndexAsync<MappingTestsParentWithArray>();
entityResult3.Wait();
}
if (context.IndexExists<MappingTestsParentWithSimpleList>())
{
context.AllowDeleteForIndex = true;
var entityResult4 = context.DeleteIndexAsync<MappingTestsParentWithSimpleList>();
entityResult4.Wait();
}
if (context.IndexExists<MappingTestsParentNull>())
{
context.AllowDeleteForIndex = true;
var entityResult5 = context.DeleteIndexAsync<MappingTestsParentNull>();
entityResult5.Wait();
}
if (context.IndexExists<MappingTestsParentWithListNull>())
{
context.AllowDeleteForIndex = true;
var entityResult6 = context.DeleteIndexAsync<MappingTestsParentWithListNull>();
entityResult6.Wait();
}
if (context.IndexExists<MappingTestsParentWithArrayNull>())
{
context.AllowDeleteForIndex = true;
var entityResult7 = context.DeleteIndexAsync<MappingTestsParentWithArrayNull>();
entityResult7.Wait();
}
if (context.IndexExists<MappingTestsParentWithSimpleNullAndNullArrayList>())
{
context.AllowDeleteForIndex = true;
var entityResult8 = context.DeleteIndexAsync<MappingTestsParentWithSimpleNullAndNullArrayList>();
entityResult8.Wait();
}
}
}
示例15: CreateNewIndexAndMappingForNestedChildInTwoStepsWithRouting
public void CreateNewIndexAndMappingForNestedChildInTwoStepsWithRouting()
{
const string index = "newindextestmappingtwostep";
IElasticsearchMappingResolver elasticsearchMappingResolver;
var mappingTestsParent = SetupIndexMappingTests(index, out elasticsearchMappingResolver);
var routing = new RoutingDefinition {RoutingId = "coolrouting"};
var config = new ElasticsearchSerializerConfiguration(elasticsearchMappingResolver,true,false,true);
using (var context = new ElasticsearchContext(ConnectionString, config))
{
context.AllowDeleteForIndex = true;
context.TraceProvider = new ConsoleTraceProvider();
context.IndexCreate(index);
Thread.Sleep(1500);
Assert.IsTrue(context.IndexExists<MappingTestsParent>());
context.IndexCreateTypeMapping<MappingTestsParent>(new MappingDefinition { Index = index, RoutingDefinition = routing });
Thread.Sleep(1500);
context.AddUpdateDocument(mappingTestsParent, mappingTestsParent.MappingTestsParentId, routing);
context.SaveChanges();
Thread.Sleep(1500);
var doc = context.GetDocument<MappingTestsParent>(mappingTestsParent.MappingTestsParentId, routing);
Thread.Sleep(1500);
Assert.IsNotNull(doc);
context.DeleteIndexType<MappingTestsParent>();
Thread.Sleep(1500);
Assert.IsFalse(context.IndexTypeExists<MappingTestsParent>());
if (context.IndexExists<MappingTestsParent>())
{
context.DeleteIndex<MappingTestsParent>();
}
}
}