本文整理汇总了C#中ElasticsearchContext.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# ElasticsearchContext.SaveChanges方法的具体用法?C# ElasticsearchContext.SaveChanges怎么用?C# ElasticsearchContext.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElasticsearchContext
的用法示例。
在下文中一共展示了ElasticsearchContext.SaveChanges方法的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();
}
}
示例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"));
}
}
示例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);
}
}
示例4: 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
示例5: 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);
}
}
示例6: 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);
}
}
示例7: 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]);
}
}
示例8: 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
示例9: 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);
}
}
}
}
示例10: TestDefaultContextParentWithSingleChildEqualsNull
public void TestDefaultContextParentWithSingleChildEqualsNull()
{
using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
{
context.TraceProvider = new ConsoleTraceProvider();
var skillWithSingleChild = new SkillWithSingleChild {MySkillSingleChildElement = null};
context.AddUpdateDocument(skillWithSingleChild, skillWithSingleChild.Id);
// Save to Elasticsearch
var ret = context.SaveChanges();
Assert.AreEqual(ret.Status, HttpStatusCode.OK);
var roundTripResult = context.GetDocument<SkillWithSingleChild>(skillWithSingleChild.Id);
Assert.AreEqual(roundTripResult.BlahBlah, skillWithSingleChild.BlahBlah);
}
}
示例11: TestDefaultContextParentWithNullCollectionNested
public void TestDefaultContextParentWithNullCollectionNested()
{
using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
{
context.TraceProvider = new ConsoleTraceProvider();
var skill = new SkillParentCollection
{
CreatedSkillParent = DateTime.UtcNow,
UpdatedSkillParent = DateTime.UtcNow,
Id = 34,
NameSkillParent = "rr",
DescriptionSkillParent = "ee"
};
context.AddUpdateDocument(skill, skill.Id);
// Save to Elasticsearch
var ret = context.SaveChanges();
Assert.AreEqual(ret.Status, HttpStatusCode.OK);
var roundTripResult = context.GetDocument<SkillParentCollection>(skill.Id);
Assert.AreEqual(roundTripResult.DescriptionSkillParent, skill.DescriptionSkillParent);
}
}
示例12: AddSearchHightlightResultDataFastestAnimalPostings
private void AddSearchHightlightResultDataFastestAnimalPostings()
{
using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
{
context.IndexCreate<FastestAnimalPostings>();
Thread.Sleep(1200);
var animals = new List<FastestAnimalPostings>
{
new FastestAnimalPostings {Id = 1, AnimalName = "Cheetah", Speed = "112–120 km/h (70–75 mph)", SpeedMph="70–75 mph", SpeedKmh="112–120 km/h", Data = "The Cheetah can accelerate from 0 to 96.6 km/h (60.0 mph) in under three seconds, though endurance is limited: most Cheetahs run for only 60 seconds at a time. When sprinting, cheetahs spend more time in the air than on the ground."},
new FastestAnimalPostings {Id = 2, AnimalName = "Free-tailed bat", Speed = "96.6 km/h (60.0 mph)", SpeedMph="60.0 mph", SpeedKmh="96.6 km/h",Data = "Some attribute such flying capabilities specifically to the Mexican free-tailed bat. Tail wind is what allows free-tailed bats to reach such high speeds."},
new FastestAnimalPostings {Id = 3, AnimalName = "Pronghorn", Speed = "96.6 km/h (60.0 mph)", SpeedMph="60.0 mph", SpeedKmh="96.6 km/h",Data = "The pronghorn (American antelope) is the fastest animal over long distances; it can run 56 km/h for 6 km (35 mph for 4 mi), 67 km/h for 1.6 km (42 mph for 1 mi), and 88.5 km/h for .8 km (55 mph for .5 mi)."},
new FastestAnimalPostings {Id = 4, AnimalName = "Springbok", Speed = "88 km/h (55 mph)", SpeedMph="55 mph", SpeedKmh="88 km/h",Data = "The springbok, an antelope of the gazelle tribe in southern Africa, can make long jumps and sharp turns while running. Unlike pronghorns, springboks are poor long-distance runners."},
new FastestAnimalPostings {Id = 5, AnimalName = "Wildebeest", Speed = "80.5 km/h (50.0 mph)", SpeedMph="50.0 mph", SpeedKmh="80.5 km/h",Data = "The wildebeest, an antelope, exists as two species: the blue wildebeest and the black wildebeest. Both are extremely fast runners, which allows them to flee from predators. They are better at endurance running than at sprinting."},
new FastestAnimalPostings {Id = 6, AnimalName = "Blackbuck", Speed = "80 km/h (50 mph)", SpeedMph="50 mph", SpeedKmh="80 km/h",Data = "The blackbuck antelope can sustain speeds of 80 km/h (50 mph) for over 1.5 km (0.93 mi) at a time. Each of its strides (i.e., the distance between its hoofprints) is 5.8–6.7 m (19–22 ft)."},
new FastestAnimalPostings {Id = 7, AnimalName = "Lion", Speed = "80 km/h (50 mph)", SpeedMph="50 mph", SpeedKmh="80 km/h",Data = "Lionesses are faster than males and can reach maximum speeds of 35 mph (57 km/h) in short distances of approximately 90 meters, and a top speed of 50 mph (80 km/h) for about 20 meters. Lions are very agile and have fast reflexes. Like other predators, they hunt sick prey. Their rate of success in hunting is greatest at night. Lions hunt buffalos, giraffes, warthogs, wildebeests and zebras, and sometimes various antelopes as opportunities present themselves."},
new FastestAnimalPostings {Id = 8, AnimalName = "Greyhound", Speed = "74 km/h (46 mph)", SpeedMph="46 mph", SpeedKmh="74 km/h",Data = "Greyhounds are the fastest dogs, and have primarily been bred for coursing game and racing."},
new FastestAnimalPostings {Id = 9, AnimalName = "Jackrabbit", Speed = "72 km/h (45 mph)", SpeedMph="45 mph", SpeedKmh="72 km/h",Data = "The jackrabbit's strong hind legs allow it to leap 3 m (9.8 ft) in one bound; some can even reach 6 m (20 ft). Jackrabbits use a combination of leaps and zig-zags to outrun predators."},
new FastestAnimalPostings {Id = 10, AnimalName = "African wild dog", Speed = "71 km/h (44 mph)", SpeedMph="44 mph", SpeedKmh="71 km/h",Data = "When hunting, African wild dogs can sprint at 66 km/h (41 mph) in bursts, and they can maintain speeds of 56–60 km/h (35–37 mph) for up to 4.8 km (3 mi). Their targeted prey rarely escapes."},
new FastestAnimalPostings {Id = 11, AnimalName = "Kangaroo", Speed = "71 km/h (44 mph)", SpeedMph="44 mph", SpeedKmh="71 km/h",Data = "The comfortable hopping speed for a kangaroo is about 21–26 km/h (13–16 mph), but speeds of up to 71 km/h (44 mph) can be attained over short distances, while it can sustain a speed of 40 km/h (25 mph) for nearly 2 km (1.2 mi). The faster a kangaroo hops, the less energy it consumes (up to its cruising speed)."},
new FastestAnimalPostings {Id = 12, AnimalName = "Horse", Speed = "70.76 km/h (43.97 mph)", SpeedMph="43.97 mph", SpeedKmh="70.76 km/h",Data = "The fastest horse speed was achieved by a Quarter horse. It reached 70.76 km/h (43.97 mph)."},
new FastestAnimalPostings {Id = 13, AnimalName = "Onager", Speed = "70 km/h (43 mph)", SpeedMph="43 mph", SpeedKmh="70 km/h",Data = "The onager consists of several subspecies, which most likely share the same ability to run at high speeds."},
new FastestAnimalPostings {Id = 14, AnimalName = "Thomson's gazelle", Speed = "70 km/h (43 mph)", SpeedMph="43 mph", SpeedKmh="70 km/h",Data = "Thomson's gazelles, being long-distance runners, can escape cheetahs by sheer endurance. Their speed is partially due to their \"stotting\", or bounding leaps."},
};
foreach (var animal in animals)
{
context.AddUpdateDocument(animal, animal.Id);
}
context.SaveChanges();
}
}
示例13: TestCreateIndexNewChildItemTestParentDoesNotExist
public void TestCreateIndexNewChildItemTestParentDoesNotExist()
{
const int parentId = 332;
// This creates a new child doc with the parent 332 even though no parent for 332 exists
using (var context = new ElasticsearchContext(ConnectionString, new ElasticsearchSerializerConfiguration(_elasticsearchMappingResolver, SaveChildObjectsAsWellAsParent, ProcessChildDocumentsAsSeparateChildIndex)))
{
var testObject = new ChildDocumentLevelTwo
{
Id = 47,
D3 = "DoesNotExist.p332.p47"
};
context.TraceProvider = new ConsoleTraceProvider();
context.AddUpdateDocument(testObject, testObject.Id, new RoutingDefinition { ParentId = parentId });
// Save to Elasticsearch
var ret = context.SaveChanges();
Assert.AreEqual(ret.Status, HttpStatusCode.OK);
Thread.Sleep(1500);
var roundTripResult = context.GetDocument<ChildDocumentLevelTwo>(testObject.Id, new RoutingDefinition { ParentId = parentId });
var childDocs = context.Search<ChildDocumentLevelTwo>(BuildSearchForChildDocumentsWithIdAndParentType(parentId, "childdocumentlevelone"));
Assert.IsNotNull(childDocs.PayloadResult.Hits.HitsResult.First(t => t.Id.ToString() == "47"));
Assert.AreEqual(testObject.Id, roundTripResult.Id);
}
}
示例14: 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);
}
}
示例15: 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);
}
}