fix: add document
All checks were successful
build-packages / meilisearch-dotnet-packages (push) Successful in 4m11s

This commit is contained in:
Damien 2025-02-25 03:11:59 -05:00
parent a8aa7ddf0d
commit 63dfbd8762
4 changed files with 47 additions and 1 deletions

View File

@ -13,6 +13,7 @@ MeiliSearch .NET Integration is a NuGet package that seamlessly embeds MeiliSear
- [x] **Embedded MeiliSearch**: Integrate MeiliSearch directly into your application.
- [x] **Manage Indexes**: Manage your indexs and documents through the SDK, you can still use the default Meilisearch SDK.
- [x] **Add Documents**: Ability to add documents and have validation on if the index is loaded.
- [x] **Background Process Management**: Automatically handles the lifecycle of the MeiliSearch process.
- [x] **Health Monitoring**: Regular checks on the health of the MeiliSearch instance to ensure it stays running.
- [x] **API Key Management**: An API key is automatically regenerated every time the MeiliSearch service starts unless one is specified in the configuration.

View File

@ -3,6 +3,7 @@ using System.Net;
using System.Threading.Tasks;
using meilisearch.NET;
using meilisearch.NET.Configurations;
using meilisearch.NET.example;
using meilisearch.NET.Extensions;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@ -61,7 +62,42 @@ public class test
Task.Delay(1000).Wait(); // Wait for 1 second before checking again
}
service.CreateIndex("test");
service.CreateIndex<document>("test");
service.AddDocument("test", new document()
{
Id = Guid.NewGuid(),
message = "Hello, Meilisearch!"
});
service.AddDocument("test", new document()
{
Id = Guid.NewGuid(),
message = "Hello, Meilisearch!"
});
service.AddDocument("test", new document()
{
Id = Guid.NewGuid(),
message = "Hello, Meilisearch!"
});
service.AddDocument("test", new document()
{
Id = Guid.NewGuid(),
message = "Hello, Meilisearch!"
});
service.AddDocument("test", new document()
{
Id = Guid.NewGuid(),
message = "Hello, Meilisearch!"
});
service.AddDocument("test", new document()
{
Id = Guid.NewGuid(),
message = "Hello, Meilisearch!"
});
service.AddDocument("test", new document()
{
Id = Guid.NewGuid(),
message = "Hello, Meilisearch!"
});
_logger.LogInformation("Test service initialized.");
}
}

View File

@ -0,0 +1,8 @@
using meilisearch.NET.Interfaces;
namespace meilisearch.NET.example;
public class document:IDocument
{
public string message { get; set; }
}

View File

@ -40,6 +40,7 @@ public class MeilisearchService:IDisposable
_documentCollection.CollectionChanged += CheckIfNeedDocumentSync;
StartMeilisearch().Wait();
EnsureRepositoryIndexExists().Wait();
_logger.LogTrace("API Key: " + _apiKey);
}