Skip to content

Commit

Permalink
updating elastic api changes
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed May 20, 2016
1 parent f559bae commit 83bf879
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ public void SearchQueryGeoHashFilter()
var search = new Search { Filter = new Filter(
new GeohashCellFilter(
"location",
new GeoPoint(43, 43),
new GeoPoint(45, 45),
3,
true))
};
Expand All @@ -602,7 +602,7 @@ public void SearchQueryGeoHashFilter()
context.TraceProvider = new ConsoleTraceProvider();
Assert.True(context.IndexTypeExists<SearchTest>());
var items = context.Search<SearchTest>(search);
Assert.Equal(1, items.PayloadResult.Hits.Total);
Assert.Equal(2, items.PayloadResult.Hits.Total);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,48 @@

namespace ElasticsearchCRUD.Integration.Test.SearchTests
{
public class SetupSearch
{
protected readonly IElasticsearchMappingResolver ElasticsearchMappingResolver = new ElasticsearchMappingResolver();
protected const string ConnectionString = "http://localhost:9200";
public class SetupSearch
{
protected readonly IElasticsearchMappingResolver ElasticsearchMappingResolver = new ElasticsearchMappingResolver();
protected const string ConnectionString = "http://localhost:9200";

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)
};
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))
{
if (!context.IndexExists<SearchTest>())
{
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))
{
if (!context.IndexExists<SearchTest>())
{
context.IndexCreate<SearchTest>();
Thread.Sleep(1500);
context.AddUpdateDocument(doc1, doc1.Id);
Expand All @@ -54,16 +54,16 @@ public void Setup()
context.SaveChanges();
Thread.Sleep(1500);
}
}
}
}
}

public void TearDown()
{
using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
{
context.AllowDeleteForIndex = true;
var entityResult = context.DeleteIndexAsync<SearchTest>(); entityResult.Wait();
}
}
}
public void TearDown()
{
using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
{
context.AllowDeleteForIndex = true;
var entityResult = context.DeleteIndexAsync<SearchTest>(); entityResult.Wait();
}
}
}
}

0 comments on commit 83bf879

Please sign in to comment.