diff --git a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Recipes/LuceneRecipeEventHandler.cs b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Recipes/LuceneRecipeEventHandler.cs index 2993348538d..e72bcc31344 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Recipes/LuceneRecipeEventHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Recipes/LuceneRecipeEventHandler.cs @@ -47,10 +47,9 @@ public Task RecipeStepExecutingAsync(RecipeExecutionContext context) { if (partDefinition.Settings != null) { - if (partDefinition.Settings.TryGetPropertyValue("ContentIndexSettings", out var existingPartSettings) && - !partDefinition.Settings.ContainsKey("LuceneContentIndexSettings")) + if (partDefinition.Settings.TryGetPropertyValue("ContentIndexSettings", out var existingPartSettings)) { - partDefinition.Settings.Add("LuceneContentIndexSettings", existingPartSettings); + partDefinition.Settings["LuceneContentIndexSettings"] = existingPartSettings; } partDefinition.Settings.Remove("ContentIndexSettings"); @@ -59,10 +58,9 @@ public Task RecipeStepExecutingAsync(RecipeExecutionContext context) { if (fieldDefinition.Settings != null) { - if (fieldDefinition.Settings.TryGetPropertyValue("ContentIndexSettings", out var existingFieldSettings) && - !fieldDefinition.Settings.ContainsKey("LuceneContentIndexSettings")) + if (fieldDefinition.Settings.TryGetPropertyValue("ContentIndexSettings", out var existingFieldSettings)) { - fieldDefinition.Settings.Add("LuceneContentIndexSettings", existingFieldSettings); + fieldDefinition.Settings["LuceneContentIndexSettings"] = existingFieldSettings; } fieldDefinition.Settings.Remove("ContentIndexSettings"); diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Migrations.cs index abaded663ab..e3358df23ea 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Migrations.cs @@ -81,7 +81,7 @@ await _contentDefinitionManager.AlterPartDefinitionAsync(partDefinition.Name, pa jExistingPartSettings.Remove("Tokenized"); jExistingPartSettings.Remove("Template"); - partDefinition.Settings.Add(nameof(LuceneContentIndexSettings), jExistingPartSettings.Clone()); + partDefinition.Settings[nameof(LuceneContentIndexSettings)] = jExistingPartSettings.Clone(); } partDefinition.Settings.Remove("ContentIndexSettings"); @@ -125,8 +125,7 @@ await _contentDefinitionManager.AlterPartDefinitionAsync(partDefinition.Name, pa jExistingPartSettings.Remove("Analyzed"); jExistingPartSettings.Remove("Tokenized"); jExistingPartSettings.Remove("Template"); - - partDefinition.Settings.Add(nameof(LuceneContentIndexSettings), jExistingPartSettings.Clone()); + partDefinition.Settings[nameof(LuceneContentIndexSettings)] = jExistingPartSettings.Clone(); } partDefinition.Settings.Remove("ContentIndexSettings"); diff --git a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexingService.cs b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexingService.cs index 56aae46af4c..1e674e3a1e6 100644 --- a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexingService.cs +++ b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexingService.cs @@ -297,7 +297,7 @@ await _contentDefinitionManager.AlterPartDefinitionAsync(partDefinition.Name, pa if (included is not null && (bool)included) { - partDefinition.Settings.Add(nameof(ElasticContentIndexSettings), JNode.FromObject(existingPartSettings.ToObject())); + partDefinition.Settings[nameof(ElasticContentIndexSettings)] = JNode.FromObject(existingPartSettings.ToObject()); } } }); @@ -316,7 +316,7 @@ await _contentDefinitionManager.AlterPartDefinitionAsync(partDefinition.Name, pa if (included != null && (bool)included) { - partDefinition.Settings.Add(nameof(ElasticContentIndexSettings), JNode.FromObject(existingPartSettings.ToObject())); + partDefinition.Settings[nameof(ElasticContentIndexSettings)] = JNode.FromObject(existingPartSettings.ToObject()); } } @@ -328,7 +328,7 @@ await _contentDefinitionManager.AlterPartDefinitionAsync(partDefinition.Name, pa if (included != null && (bool)included) { - fieldDefinition.Settings.Add(nameof(ElasticContentIndexSettings), JNode.FromObject(existingFieldSettings.ToObject())); + fieldDefinition.Settings[nameof(ElasticContentIndexSettings)] = JNode.FromObject(existingFieldSettings.ToObject()); } } }