Skip to content

Instantly share code, notes, and snippets.

@awswithdotnet
Created March 8, 2022 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awswithdotnet/d57f5fa19c49b6077a6f43b072790ba1 to your computer and use it in GitHub Desktop.
Save awswithdotnet/d57f5fa19c49b6077a6f43b072790ba1 to your computer and use it in GitHub Desktop.
elasticsearch DataCreate Program Complete
using System;
using System.Threading.Tasks;
using Abstractions;
using Domain;
using Nest;
using Elasticsearch;
namespace DataCreate
{
class Program
{
static async Task Main(string[] args)
{
IElasticSearchConnectionSettingsFactory elasticSearchConnectionSettingsFactory = new ElasticSearchStaticConnectionSettingsFactory();
IElasticSearchClientFactory elasticSearchClientFactory = new ElasticSearchClientFactory(elasticSearchConnectionSettingsFactory);
IElasticClient client = elasticSearchClientFactory.GetClient();
Vehicle vehicle = new Vehicle{
Id = Guid.NewGuid(),
Year = 2020,
Make = "BMW",
Model = "330i"
};
IndexResponse asyncIndexResponse = await client.IndexDocumentAsync(vehicle);
Console.WriteLine("Id: " + asyncIndexResponse.Id);
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment