diff --git a/src/Examine.Host/ServicesCollectionExtensions.cs b/src/Examine.Host/ServicesCollectionExtensions.cs index 8594e121..5191bf03 100644 --- a/src/Examine.Host/ServicesCollectionExtensions.cs +++ b/src/Examine.Host/ServicesCollectionExtensions.cs @@ -167,8 +167,8 @@ public static IServiceCollection AddExamineLuceneMultiSearcher( this IServiceCollection serviceCollection, string name, string[] indexNames, - Analyzer analyzer = null, - FacetsConfig facetsConfig = null) + Analyzer? analyzer = null, + FacetsConfig? facetsConfig = null) => serviceCollection.AddExamineSearcher(name, s => { IEnumerable matchedIndexes = s.GetServices() diff --git a/src/Examine.Lucene/Directories/DirectoryFactory.cs b/src/Examine.Lucene/Directories/DirectoryFactory.cs index c55000ba..725b2ca2 100644 --- a/src/Examine.Lucene/Directories/DirectoryFactory.cs +++ b/src/Examine.Lucene/Directories/DirectoryFactory.cs @@ -8,10 +8,10 @@ namespace Examine.Lucene.Directories public class GenericDirectoryFactory : DirectoryFactoryBase { private readonly Func _factory; - private readonly Func _taxonomyDirectoryFactory; + private readonly Func? _taxonomyDirectoryFactory; /// - public GenericDirectoryFactory(Func factory, Func taxonomyDirectoryFactory = null) + public GenericDirectoryFactory(Func factory, Func? taxonomyDirectoryFactory = null) { _factory = factory; _taxonomyDirectoryFactory = taxonomyDirectoryFactory; @@ -31,6 +31,11 @@ protected override Directory CreateDirectory(LuceneIndex luceneIndex, bool force /// protected override Directory CreateTaxonomyDirectory(LuceneIndex luceneIndex, bool forceUnlock) { + if(_taxonomyDirectoryFactory == null) + { + throw new InvalidOperationException("No taxonomy directory factory was specified"); + } + Directory dir = _taxonomyDirectoryFactory(luceneIndex.Name + "taxonomy"); if (forceUnlock) { diff --git a/src/Examine.Lucene/ExamineTaxonomyReplicator.cs b/src/Examine.Lucene/ExamineTaxonomyReplicator.cs index 574d118d..437ceeb6 100644 --- a/src/Examine.Lucene/ExamineTaxonomyReplicator.cs +++ b/src/Examine.Lucene/ExamineTaxonomyReplicator.cs @@ -5,6 +5,7 @@ using Lucene.Net.Replicator; using Lucene.Net.Store; using Microsoft.Extensions.Logging; +using static Lucene.Net.Documents.Field; using static Lucene.Net.Replicator.IndexAndTaxonomyRevision; using Directory = Lucene.Net.Store.Directory; @@ -142,12 +143,22 @@ public void StartIndexReplicationOnSchedule(int milliseconds) /// /// /// - private void SourceIndex_IndexCommitted(object sender, EventArgs e) + private void SourceIndex_IndexCommitted(object? sender, EventArgs? e) { - var index = (LuceneIndex)sender; - if (_logger.IsEnabled(LogLevel.Debug)) + if(sender == null) { - _logger.LogDebug("{IndexName} committed", index.Name); + if (_logger.IsEnabled(LogLevel.Debug)) + { + _logger.LogDebug("SourceIndex_IndexCommitted was called with the sender parameter being null"); + } + } + else + { + var index = (LuceneIndex)sender; + if (_logger.IsEnabled(LogLevel.Debug)) + { + _logger.LogDebug("{IndexName} committed", index.Name); + } } var rev = new IndexAndTaxonomyRevision(_sourceIndex.IndexWriter.IndexWriter, _sourceIndex.TaxonomyWriter as SnapshotDirectoryTaxonomyWriter); _replicator.Publish(rev); diff --git a/src/Examine.Lucene/Indexing/DateTimeType.cs b/src/Examine.Lucene/Indexing/DateTimeType.cs index f13d6cb4..216f4322 100644 --- a/src/Examine.Lucene/Indexing/DateTimeType.cs +++ b/src/Examine.Lucene/Indexing/DateTimeType.cs @@ -49,14 +49,15 @@ public DateTimeType(string fieldName, ILoggerFactory logger, DateResolution reso _isFacetable = false; } - public override void AddValue(Document doc, object value) + /// + public override void AddValue(Document doc, object? value) { // Support setting taxonomy path if (_isFacetable && _taxonomyIndex && value is object[] objArr && objArr != null && objArr.Length == 2) { if (!TryConvert(objArr[0], out DateTime parsedVal)) return; - if (!TryConvert(objArr[1], out string[] parsedPathVal)) + if (!TryConvert(objArr[1], out string[]? parsedPathVal)) return; var val = DateToLong(parsedVal); diff --git a/src/Examine.Lucene/Indexing/DoubleType.cs b/src/Examine.Lucene/Indexing/DoubleType.cs index c7afdaee..006d42b5 100644 --- a/src/Examine.Lucene/Indexing/DoubleType.cs +++ b/src/Examine.Lucene/Indexing/DoubleType.cs @@ -42,14 +42,14 @@ public DoubleType(string fieldName, ILoggerFactory logger, bool store = true) public bool IsTaxonomyFaceted => _taxonomyIndex; /// - public override void AddValue(Document doc, object value) + public override void AddValue(Document doc, object? value) { // Support setting taxonomy path if (_isFacetable && _taxonomyIndex && value is object[] objArr && objArr != null && objArr.Length == 2) { if (!TryConvert(objArr[0], out double parsedVal)) return; - if (!TryConvert(objArr[1], out string[] parsedPathVal)) + if (!TryConvert(objArr[1], out string[]? parsedPathVal)) return; doc.Add(new DoubleField(FieldName, parsedVal, Store ? Field.Store.YES : Field.Store.NO)); diff --git a/src/Examine.Lucene/Indexing/FullTextType.cs b/src/Examine.Lucene/Indexing/FullTextType.cs index d0437e5d..f89e53f7 100644 --- a/src/Examine.Lucene/Indexing/FullTextType.cs +++ b/src/Examine.Lucene/Indexing/FullTextType.cs @@ -81,14 +81,14 @@ public FullTextType(string fieldName, ILoggerFactory logger, Analyzer? analyzer public bool IsTaxonomyFaceted => _taxonomyIndex; /// - public override void AddValue(Document doc, object value) + public override void AddValue(Document doc, object? value) { // Support setting taxonomy path if (_isFacetable && _taxonomyIndex && value is object[] objArr && objArr != null && objArr.Length == 2) { - if (!TryConvert(objArr[0], out string str)) + if (!TryConvert(objArr[0], out string? str)) return; - if (!TryConvert(objArr[1], out string[] parsedPathVal)) + if (!TryConvert(objArr[1], out string[]? parsedPathVal)) return; doc.Add(new TextField(FieldName, str, Field.Store.YES)); @@ -108,6 +108,7 @@ public override void AddValue(Document doc, object value) base.AddValue(doc, value); } + /// protected override void AddSingleValue(Document doc, object value) { if (TryConvert(value, out var str)) diff --git a/src/Examine.Lucene/Indexing/Int32Type.cs b/src/Examine.Lucene/Indexing/Int32Type.cs index 2521d949..c3b4a169 100644 --- a/src/Examine.Lucene/Indexing/Int32Type.cs +++ b/src/Examine.Lucene/Indexing/Int32Type.cs @@ -42,14 +42,14 @@ public Int32Type(string fieldName, ILoggerFactory logger, bool store = true) public bool IsTaxonomyFaceted => _taxonomyIndex; /// - public override void AddValue(Document doc, object value) + public override void AddValue(Document doc, object? value) { // Support setting taxonomy path if (_isFacetable && _taxonomyIndex && value is object[] objArr && objArr != null && objArr.Length == 2) { if (!TryConvert(objArr[0], out int parsedVal)) return; - if (!TryConvert(objArr[1], out string[] parsedPathVal)) + if (!TryConvert(objArr[1], out string[]? parsedPathVal)) return; doc.Add(new Int32Field(FieldName, parsedVal, Store ? Field.Store.YES : Field.Store.NO)); @@ -61,6 +61,7 @@ public override void AddValue(Document doc, object value) base.AddValue(doc, value); } + /// protected override void AddSingleValue(Document doc, object value) { if (!TryConvert(value, out int parsedVal)) diff --git a/src/Examine.Lucene/Indexing/Int64Type.cs b/src/Examine.Lucene/Indexing/Int64Type.cs index 52412415..f231c47c 100644 --- a/src/Examine.Lucene/Indexing/Int64Type.cs +++ b/src/Examine.Lucene/Indexing/Int64Type.cs @@ -42,14 +42,14 @@ public Int64Type(string fieldName, ILoggerFactory logger, bool store = true) public bool IsTaxonomyFaceted => _taxonomyIndex; /// - public override void AddValue(Document doc, object value) + public override void AddValue(Document doc, object? value) { // Support setting taxonomy path if (_isFacetable && _taxonomyIndex && value is object[] objArr && objArr != null && objArr.Length == 2) { if (!TryConvert(objArr[0], out long parsedVal)) return; - if (!TryConvert(objArr[1], out string[] parsedPathVal)) + if (!TryConvert(objArr[1], out string[]? parsedPathVal)) return; doc.Add(new Int64Field(FieldName, parsedVal, Store ? Field.Store.YES : Field.Store.NO)); @@ -61,6 +61,7 @@ public override void AddValue(Document doc, object value) base.AddValue(doc, value); } + /// protected override void AddSingleValue(Document doc, object value) { if (!TryConvert(value, out long parsedVal)) diff --git a/src/Examine.Lucene/Indexing/SingleType.cs b/src/Examine.Lucene/Indexing/SingleType.cs index 132877f2..0c9a4a59 100644 --- a/src/Examine.Lucene/Indexing/SingleType.cs +++ b/src/Examine.Lucene/Indexing/SingleType.cs @@ -43,14 +43,14 @@ public SingleType(string fieldName, ILoggerFactory logger, bool store = true) public bool IsTaxonomyFaceted => _taxonomyIndex; /// - public override void AddValue(Document doc, object value) + public override void AddValue(Document doc, object? value) { // Support setting taxonomy path if (_isFacetable && _taxonomyIndex && value is object[] objArr && objArr != null && objArr.Length == 2) { if (!TryConvert(objArr[0], out float parsedVal)) return; - if (!TryConvert(objArr[1], out string[] parsedPathVal)) + if (!TryConvert(objArr[1], out string[]? parsedPathVal)) return; doc.Add(new DoubleField(FieldName, parsedVal, Store ? Field.Store.YES : Field.Store.NO)); @@ -62,6 +62,7 @@ public override void AddValue(Document doc, object value) base.AddValue(doc, value); } + /// protected override void AddSingleValue(Document doc, object value) { if (!TryConvert(value, out float parsedVal)) diff --git a/src/Examine.Lucene/Providers/LuceneIndex.cs b/src/Examine.Lucene/Providers/LuceneIndex.cs index a41e3310..e2af0300 100644 --- a/src/Examine.Lucene/Providers/LuceneIndex.cs +++ b/src/Examine.Lucene/Providers/LuceneIndex.cs @@ -39,7 +39,7 @@ protected LuceneIndex( string name, IOptionsMonitor indexOptions, Func indexCommiterFactory, - IndexWriter writer = null) + IndexWriter? writer = null) : base(loggerFactory, name, indexOptions) { _options = indexOptions.GetNamedOptions(name); @@ -190,7 +190,7 @@ internal LuceneIndex( /// /// Gets a Taxonomy searcher for the index /// - public virtual ILuceneTaxonomySearcher TaxonomySearcher => _taxonomySearcher.Value; + public virtual ILuceneTaxonomySearcher? TaxonomySearcher => _taxonomySearcher?.Value; /// /// The async task that runs during an async indexing operation @@ -212,11 +212,11 @@ internal LuceneIndex( // tracks the latest Generation value of what has been indexed.This can be used to force update a searcher to this generation. private long? _latestGen; - private volatile DirectoryTaxonomyWriter _taxonomyWriter; - private ControlledRealTimeReopenThread _taxonomyNrtReopenThread; + private volatile DirectoryTaxonomyWriter? _taxonomyWriter; + private ControlledRealTimeReopenThread? _taxonomyNrtReopenThread; - private readonly Lazy _taxonomySearcher; - private readonly Lazy _taxonomyDirectory; + private readonly Lazy? _taxonomySearcher; + private readonly Lazy? _taxonomyDirectory; #region Properties @@ -428,6 +428,12 @@ public void EnsureIndex(bool forceOverwrite) { //Now create the taxonomy index var taxonomyDir = GetLuceneTaxonomyDirectory(); + + if(taxonomyDir == null) + { + throw new InvalidOperationException($"{Name} is configured to use a taxonomy index but the directory is null"); + } + CreateNewTaxonomyIndex(taxonomyDir); } } @@ -539,7 +545,7 @@ private void CreateNewIndex(Directory? dir) /// private void CreateNewTaxonomyIndex(Directory dir) { - DirectoryTaxonomyWriter writer = null; + DirectoryTaxonomyWriter? writer = null; try { if (IsLocked(dir)) @@ -779,7 +785,7 @@ private bool IndexExistsImpl() return _exists.Value; } - // + /// /// This will check one time if the taxonomny index exists, we don't want to keep using IndexReader.IndexExists because that will literally go list /// every file in the index folder and we don't need any more IO ops /// @@ -1082,7 +1088,7 @@ private bool ProcessQueueItem(IndexOperation item) /// Returns the Lucene Directory used to store the taxonomy index /// /// - public Directory GetLuceneTaxonomyDirectory() => _taxonomyWriter != null ? _taxonomyWriter.Directory : _taxonomyDirectory.Value; + public Directory? GetLuceneTaxonomyDirectory() => _taxonomyWriter != null ? _taxonomyWriter.Directory : _taxonomyDirectory?.Value; /// @@ -1211,9 +1217,9 @@ public TrackingIndexWriter IndexWriter /// Used to create an index writer - this is called in GetIndexWriter (and therefore, GetIndexWriter should not be overridden) /// /// - private DirectoryTaxonomyWriter CreateTaxonomyWriterInternal() + private DirectoryTaxonomyWriter? CreateTaxonomyWriterInternal() { - Directory dir = GetLuceneTaxonomyDirectory(); + Directory? dir = GetLuceneTaxonomyDirectory(); // Unfortunatley if the appdomain is taken down this will remain locked, so we can // ensure that it's unlocked here in that case. @@ -1245,7 +1251,7 @@ private DirectoryTaxonomyWriter CreateTaxonomyWriterInternal() /// /// /// - protected virtual DirectoryTaxonomyWriter CreateTaxonomyWriter(Directory d) + protected virtual DirectoryTaxonomyWriter CreateTaxonomyWriter(Directory? d) { if (d == null) { @@ -1279,7 +1285,7 @@ public DirectoryTaxonomyWriter TaxonomyWriter } - return _taxonomyWriter; + return _taxonomyWriter; // TODO: should this throw when null } } @@ -1558,7 +1564,8 @@ protected virtual void Dispose(bool disposing) _nrtReopenThread.Dispose(); } - if (_taxonomyNrtReopenThread != null) + // The type of _taxonomyNrtReopenThread has overriden the != operator and expects a non null value to compare the references. Therefore we use is not null instead of != null. + if (_taxonomyNrtReopenThread is not null) { _taxonomyNrtReopenThread.Interrupt(); _taxonomyNrtReopenThread.Dispose(); diff --git a/src/Examine.Lucene/Providers/LuceneTaxonomySearcher.cs b/src/Examine.Lucene/Providers/LuceneTaxonomySearcher.cs index 08e13fc4..90c8c251 100644 --- a/src/Examine.Lucene/Providers/LuceneTaxonomySearcher.cs +++ b/src/Examine.Lucene/Providers/LuceneTaxonomySearcher.cs @@ -7,6 +7,9 @@ namespace Examine.Lucene.Providers { + /// + /// A searcher for taxonomy indexes + /// public class LuceneTaxonomySearcher : BaseLuceneSearcher, IDisposable, ILuceneTaxonomySearcher { private readonly SearcherTaxonomyManager _searcherManager; diff --git a/src/Examine.Lucene/Search/LuceneFacetLabel.cs b/src/Examine.Lucene/Search/LuceneFacetLabel.cs index a8187842..44403ae9 100644 --- a/src/Examine.Lucene/Search/LuceneFacetLabel.cs +++ b/src/Examine.Lucene/Search/LuceneFacetLabel.cs @@ -25,7 +25,7 @@ public LuceneFacetLabel(FacetLabel facetLabel) public int Length => _facetLabel.Length; /// - public int CompareTo(Examine.Search.IFacetLabel other) => _facetLabel.CompareTo(new FacetLabel(other.Components)); + public int CompareTo(Examine.Search.IFacetLabel? other) => _facetLabel.CompareTo(new FacetLabel(other?.Components)); /// public Examine.Search.IFacetLabel Subpath(int length) => new LuceneFacetLabel(_facetLabel.Subpath(length)); diff --git a/src/Examine.Lucene/Search/LuceneSearchExecutor.cs b/src/Examine.Lucene/Search/LuceneSearchExecutor.cs index e35a97a5..d0846bf6 100644 --- a/src/Examine.Lucene/Search/LuceneSearchExecutor.cs +++ b/src/Examine.Lucene/Search/LuceneSearchExecutor.cs @@ -30,7 +30,7 @@ public class LuceneSearchExecutor private int? _maxDoc; internal LuceneSearchExecutor(QueryOptions? options, Query query, IEnumerable sortField, ISearchContext searchContext, - ISet fieldsToLoad, IEnumerable facetFields, FacetsConfig facetsConfig) + ISet? fieldsToLoad, IEnumerable facetFields, FacetsConfig facetsConfig) { _options = options ?? QueryOptions.Default; _luceneQueryOptions = _options as LuceneQueryOptions; @@ -131,7 +131,7 @@ public ISearchResults Execute() { topDocsCollector = TopScoreDocCollector.Create(numHits, scoreDocAfter, true); } - FacetsCollector facetsCollector = null; + FacetsCollector? facetsCollector = null; if (_facetFields.Any() && _luceneQueryOptions != null && _luceneQueryOptions.FacetRandomSampling != null) { var facetsCollectors = new RandomSamplingFacetsCollector(_luceneQueryOptions.FacetRandomSampling.SampleSize, _luceneQueryOptions.FacetRandomSampling.Seed); @@ -216,7 +216,7 @@ private static FieldDoc GetScoreDocAfter(SearchAfterOptions searchAfterOptions) return scoreDocAfter; } - private static SearchAfterOptions GetSearchAfterOptions(TopDocs topDocs) + private static SearchAfterOptions? GetSearchAfterOptions(TopDocs topDocs) { if (topDocs.TotalHits > 0) { @@ -242,8 +242,8 @@ private IReadOnlyDictionary ExtractFacets(FacetsCollector? var facetFields = _facetFields.OrderBy(field => field.FacetField); - SortedSetDocValuesReaderState sortedSetReaderState = null; - Facets fastTaxonomyFacetCounts = null; + SortedSetDocValuesReaderState? sortedSetReaderState = null; + Facets? fastTaxonomyFacetCounts = null; foreach (var field in facetFields) diff --git a/src/Examine.Lucene/Search/LuceneSearchQuery.cs b/src/Examine.Lucene/Search/LuceneSearchQuery.cs index 7047fe8f..e07d91e0 100644 --- a/src/Examine.Lucene/Search/LuceneSearchQuery.cs +++ b/src/Examine.Lucene/Search/LuceneSearchQuery.cs @@ -347,7 +347,7 @@ internal IFacetOperations FacetInternal(string field, Action? var valueType = _searchContext.GetFieldValueType(field) as IIndexFacetValueType; - var facet = new FacetFullTextField(field, values, GetFacetField(field), isTaxonomyIndexed: valueType.IsTaxonomyFaceted); + var facet = new FacetFullTextField(field, values, GetFacetField(field), isTaxonomyIndexed: valueType?.IsTaxonomyFaceted ?? false); if(facetConfiguration != null) { @@ -367,7 +367,7 @@ internal IFacetOperations FacetInternal(string field, params DoubleRange[] doubl } var valueType = _searchContext.GetFieldValueType(field) as IIndexFacetValueType; - var facet = new FacetDoubleField(field, doubleRanges, GetFacetField(field), isTaxonomyIndexed: valueType.IsTaxonomyFaceted); + var facet = new FacetDoubleField(field, doubleRanges, GetFacetField(field), isTaxonomyIndexed: valueType?.IsTaxonomyFaceted ?? false); _facetFields.Add(facet); @@ -382,7 +382,7 @@ internal IFacetOperations FacetInternal(string field, params FloatRange[] floatR } var valueType = _searchContext.GetFieldValueType(field) as IIndexFacetValueType; - var facet = new FacetFloatField(field, floatRanges, GetFacetField(field), isTaxonomyIndexed: valueType.IsTaxonomyFaceted); + var facet = new FacetFloatField(field, floatRanges, GetFacetField(field), isTaxonomyIndexed: valueType?.IsTaxonomyFaceted ?? false); _facetFields.Add(facet); @@ -397,7 +397,7 @@ internal IFacetOperations FacetInternal(string field, params Int64Range[] longRa } var valueType = _searchContext.GetFieldValueType(field) as IIndexFacetValueType; - var facet = new FacetLongField(field, longRanges, GetFacetField(field), isTaxonomyIndexed: valueType.IsTaxonomyFaceted); + var facet = new FacetLongField(field, longRanges, GetFacetField(field), isTaxonomyIndexed: valueType?.IsTaxonomyFaceted ?? false); _facetFields.Add(facet); diff --git a/src/Examine.Lucene/Search/LuceneSearchResults.cs b/src/Examine.Lucene/Search/LuceneSearchResults.cs index baf93113..6cb70700 100644 --- a/src/Examine.Lucene/Search/LuceneSearchResults.cs +++ b/src/Examine.Lucene/Search/LuceneSearchResults.cs @@ -13,12 +13,12 @@ public class LuceneSearchResults : ILuceneSearchResults, IFacetResults /// /// Gets an empty search result /// - public static LuceneSearchResults Empty { get; } = new LuceneSearchResults(Array.Empty(), 0, new Dictionary(), float.NaN, default); + public static LuceneSearchResults Empty { get; } = new LuceneSearchResults(Array.Empty(), 0, new Dictionary(), float.NaN, null); private readonly IReadOnlyCollection _results; /// - public LuceneSearchResults(IReadOnlyCollection results, int totalItemCount, IReadOnlyDictionary facets, float maxScore, SearchAfterOptions searchAfterOptions) + public LuceneSearchResults(IReadOnlyCollection results, int totalItemCount, IReadOnlyDictionary facets, float maxScore, SearchAfterOptions? searchAfterOptions) { _results = results; TotalItemCount = totalItemCount; @@ -39,7 +39,7 @@ public LuceneSearchResults(IReadOnlyCollection results, int total /// /// Options for skipping documents after a previous search /// - public SearchAfterOptions SearchAfter { get; } + public SearchAfterOptions? SearchAfter { get; } /// public IReadOnlyDictionary Facets { get; } diff --git a/src/Examine.Lucene/Search/TaxonomySearchContext.cs b/src/Examine.Lucene/Search/TaxonomySearchContext.cs index 80d9b856..56687872 100644 --- a/src/Examine.Lucene/Search/TaxonomySearchContext.cs +++ b/src/Examine.Lucene/Search/TaxonomySearchContext.cs @@ -13,7 +13,7 @@ public class TaxonomySearchContext : ITaxonomySearchContext { private readonly SearcherTaxonomyManager _searcherManager; private readonly FieldValueTypeCollection _fieldValueTypeCollection; - private string[] _searchableFields; + private string[]? _searchableFields; /// /// Constructor diff --git a/src/Examine.Test/ExamineBaseTest.cs b/src/Examine.Test/ExamineBaseTest.cs index d15fb259..a75b6741 100644 --- a/src/Examine.Test/ExamineBaseTest.cs +++ b/src/Examine.Test/ExamineBaseTest.cs @@ -46,7 +46,7 @@ public TestIndex GetTestIndex(IndexWriter writer) writer); } - public TestIndex GetTaxonomyTestIndex(Directory d, Directory taxonomyDirectory, Analyzer analyzer, FieldDefinitionCollection fieldDefinitions = null, IndexDeletionPolicy indexDeletionPolicy = null, IReadOnlyDictionary indexValueTypesFactory = null, FacetsConfig? facetsConfig = null) + public TestIndex GetTaxonomyTestIndex(Directory d, Directory taxonomyDirectory, Analyzer analyzer, FieldDefinitionCollection fieldDefinitions = null, IndexDeletionPolicy indexDeletionPolicy = null, IReadOnlyDictionary indexValueTypesFactory = null, FacetsConfig facetsConfig = null) { var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole().SetMinimumLevel(LogLevel.Debug)); return new TestIndex(