Created
March 8, 2022 16:24
-
-
Save awswithdotnet/d57f5fa19c49b6077a6f43b072790ba1 to your computer and use it in GitHub Desktop.
elasticsearch DataCreate Program Complete
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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