Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wioniqle-q/elasticsearch-automapper
That makes you can easily auto map for elasticsearch types.
https://github.com/wioniqle-q/elasticsearch-automapper
auto automapper dotnet dotnet-core dotnet9 elasticclientselasticsearch elasticsearch indexing map mapping
Last synced: about 21 hours ago
JSON representation
That makes you can easily auto map for elasticsearch types.
- Host: GitHub
- URL: https://github.com/wioniqle-q/elasticsearch-automapper
- Owner: wioniqle-q
- License: mit
- Created: 2024-08-07T23:16:41.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-08-10T19:35:52.000Z (about 2 months ago)
- Last Synced: 2024-09-19T11:07:56.773Z (6 days ago)
- Topics: auto, automapper, dotnet, dotnet-core, dotnet9, elasticclientselasticsearch, elasticsearch, indexing, map, mapping
- Language: C#
- Homepage:
- Size: 25.4 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Elasticsearch Auto Mapper
## Description
**That makes you can easily auto-map for elasticsearch types.**## Versions
- **Elastic.Clients.Elasticseach => 8.14.9**
- **.NET Version => 9.0 Preview 6.0**## Example of the code:
```csharp
var settings = new ElasticsearchClientSettings(new Uri(""))
.Authentication(new BasicAuthentication("", ""))
.PrettyJson()
.CertificateFingerprint("")
.DisableDirectStreaming();var IndexName = "";
var client = new ElasticsearchClient(settings);await CreateIndexWithMapping(client);
private static async Task CreateIndexWithMapping(ElasticsearchClient client)
{
var exists = await client.Indices.ExistsAsync(IndexName);
if (exists.Exists)
return;
var createIndex = await client.Indices.CreateAsync(IndexName, i =>
{
i.Mappings(m =>
{
// The model you want to map can be set to T.
m.Properties(ElasticAutoMapper.MapToElasticIndex());
});
});
Console.WriteLine(createIndex.IsValidResponse
? "Index created successfully with mapping."
: $"Failed to create index: {createIndex.DebugInformation}");
}
```## Custom Attributes:
```csharp
[ElasticsearchCustomMapping] => You can make a custom maps for custom wishes.
[ElasticsearchIgnore] => Using this attribute you can write to models that you do not want to be processed.
[ElasticsearchPropertyName] => Using this attribute you can set the name of the object in your model without SneakCase.
[ElasticsearchStringMapping] => Using this attribute you can say that the object in your model is a KeywordProperty.
```