diff --git a/Directory.Build.props b/Directory.Build.props index 7c4c69f..84aadd0 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,7 +5,7 @@ $(Company) Copyright © $(Company) $([System.DateTime]::Now.Year) $(Company)™ - 1.0.3-beta-1 + 1.0.4-beta-1 MIT diff --git a/examples/DancingGoat/Search/SimpleSearchIndexingStrategy.cs b/examples/DancingGoat/Search/SimpleSearchIndexingStrategy.cs index 0aaf548..0e8e111 100644 --- a/examples/DancingGoat/Search/SimpleSearchIndexingStrategy.cs +++ b/examples/DancingGoat/Search/SimpleSearchIndexingStrategy.cs @@ -24,9 +24,9 @@ public class SimpleSearchCollectionStrategy : DefaultTypesenseCollectionStrategy private readonly IWebPageQueryResultMapper webPageMapper; private readonly IContentQueryExecutor queryExecutor; - public override ITypesenseCollectionSettings GetTypesenseCollectionSettings() + public override async Task GetTypesenseCollectionSettings() { - var baseSettings = base.GetTypesenseCollectionSettings(); + var baseSettings = await base.GetTypesenseCollectionSettings(); baseSettings.Fields.Add(new Field(nameof(SimpleSearchResultModel.Title), FieldType.String, false)); return baseSettings; } diff --git a/src/Kentico.Xperience.Typesense/Collection/DefaultTypesenseClient.cs b/src/Kentico.Xperience.Typesense/Collection/DefaultTypesenseClient.cs index 141e8be..5af9566 100644 --- a/src/Kentico.Xperience.Typesense/Collection/DefaultTypesenseClient.cs +++ b/src/Kentico.Xperience.Typesense/Collection/DefaultTypesenseClient.cs @@ -329,7 +329,7 @@ public async Task TryCreateCollection(ITypesenseConfigurationModel configu var typesenseCollection = TypesenseCollectionStore.Instance.GetCollection(configuration.CollectionName) ?? throw new InvalidOperationException($"Registered index with name '{configuration.CollectionName}' doesn't exist."); var typesenseStrategy = serviceProvider.GetRequiredStrategy(typesenseCollection); - var indexSettings = typesenseStrategy.GetTypesenseCollectionSettings(); + var indexSettings = await typesenseStrategy.GetTypesenseCollectionSettings(); var createdCollection = await searchClient.CreateCollection(indexSettings.ToSchema($"{configuration.CollectionName}-primary")); if (createdCollection == null) @@ -353,7 +353,7 @@ public async Task TryEditCollection(ITypesenseConfigurationModel configura var typesenseCollection = TypesenseCollectionStore.Instance.GetCollection(configuration.CollectionName) ?? throw new InvalidOperationException($"Registered index with name '{configuration.CollectionName}' doesn't exist."); var typesenseStrategy = serviceProvider.GetRequiredStrategy(typesenseCollection); - var indexSettings = typesenseStrategy.GetTypesenseCollectionSettings(); + var indexSettings = await typesenseStrategy.GetTypesenseCollectionSettings(); var currentCollection = await searchClient.RetrieveCollection(configuration.CollectionName); //Search by alias the current collection @@ -379,7 +379,7 @@ public async Task TryEditCollection(ITypesenseConfigurationModel configura public async Task EnsureNewCollection(string newCollection, TypesenseCollection typesenseCollection) { var typesenseStrategy = serviceProvider.GetRequiredStrategy(typesenseCollection); - var indexSettings = typesenseStrategy.GetTypesenseCollectionSettings(); + var indexSettings = await typesenseStrategy.GetTypesenseCollectionSettings(); var allCollections = await searchClient.RetrieveCollections(); diff --git a/src/Kentico.Xperience.Typesense/Collection/DefaultTypesenseIndexingStrategy.cs b/src/Kentico.Xperience.Typesense/Collection/DefaultTypesenseIndexingStrategy.cs index e6a3f9b..834a670 100644 --- a/src/Kentico.Xperience.Typesense/Collection/DefaultTypesenseIndexingStrategy.cs +++ b/src/Kentico.Xperience.Typesense/Collection/DefaultTypesenseIndexingStrategy.cs @@ -30,16 +30,16 @@ public class DefaultTypesenseCollectionStrategy : ITypesenseCollectionStrategy return Task.FromResult?>(result); } - public virtual ITypesenseCollectionSettings GetTypesenseCollectionSettings() => new TypesenseCollectionSettings() - { - Fields = - [ + public virtual Task GetTypesenseCollectionSettings() => + Task.FromResult(new TypesenseCollectionSettings() + { + Fields = new(){ new Field(BaseObjectProperties.ITEM_GUID, FieldType.String), new Field(BaseObjectProperties.CONTENT_TYPE_NAME, FieldType.String), new Field(BaseObjectProperties.LANGUAGE_NAME, FieldType.String), new Field(BaseObjectProperties.URL, FieldType.String), - ] - }; + } + }); public virtual async Task> FindItemsToReindex(CollectionEventWebPageItemModel changedItem) => await Task.FromResult(new List() { changedItem }); diff --git a/src/Kentico.Xperience.Typesense/Collection/ITypesenseIndexingStrategy.cs b/src/Kentico.Xperience.Typesense/Collection/ITypesenseIndexingStrategy.cs index dee6209..cf7dd49 100644 --- a/src/Kentico.Xperience.Typesense/Collection/ITypesenseIndexingStrategy.cs +++ b/src/Kentico.Xperience.Typesense/Collection/ITypesenseIndexingStrategy.cs @@ -10,7 +10,7 @@ public interface ITypesenseCollectionStrategy /// Modified Typesense document. Task?> MapToTypesenseObjectsOrNull(ICollectionEventItemModel typesensePageItem); - ITypesenseCollectionSettings GetTypesenseCollectionSettings(); + Task GetTypesenseCollectionSettings(); Task> FindItemsToReindex(CollectionEventWebPageItemModel changedItem);