using AobaCore.Models; using Microsoft.Extensions.Hosting; using MongoDB.Driver; namespace AobaCore; public class AobaIndexCreationService(IMongoDatabase db): BackgroundService { private readonly IMongoCollection _media = db.GetCollection("media"); protected override async Task ExecuteAsync(CancellationToken stoppingToken) { var textKeys = Builders.IndexKeys .Text(m => m.Filename); var textModel = new CreateIndexModel(textKeys, new CreateIndexOptions { Name = "Text", Background = true }); await _media.EnsureIndexAsync(textModel); } }