Slide 12
Slide 12 text
緯度経度のデータをインポート
using (var connection = ApiConnection.Create("", ""))
using (var client = new IndexManagementClient(connection))
{
var json = File.ReadAllText(@"C:¥Gourmet.json", Encoding.UTF8);
var targets = JsonConvert.DeserializeObject>(json);
foreach (var target in targets.Select((v, i) => new { value = v, index = i }))
{
var populateResponse = await client.PopulateAsync("",
new IndexOperation(IndexOperationType.Upload,
"id", (target.index + 1).ToString())
.WithProperty("title", target.value.Title)
.WithProperty("restaurant", target.value.Restaurant)
.WithProperty("location", new { type = "Point",
coordinates = new[] { target.value.Location.lng, target.value.Location.lat } }));
}
}