Skip to content

Commit

Permalink
Check for elastic settings before updating. (#16915)
Browse files Browse the repository at this point in the history
  • Loading branch information
PBMikeW authored Oct 29, 2024
1 parent c3b61cf commit 701c07e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ElasticContentIndexSettings>()));
partDefinition.Settings[nameof(ElasticContentIndexSettings)] = JNode.FromObject(existingPartSettings.ToObject<ElasticContentIndexSettings>());
}
}
});
Expand All @@ -316,7 +316,7 @@ await _contentDefinitionManager.AlterPartDefinitionAsync(partDefinition.Name, pa
if (included != null && (bool)included)
{
partDefinition.Settings.Add(nameof(ElasticContentIndexSettings), JNode.FromObject(existingPartSettings.ToObject<ElasticContentIndexSettings>()));
partDefinition.Settings[nameof(ElasticContentIndexSettings)] = JNode.FromObject(existingPartSettings.ToObject<ElasticContentIndexSettings>());
}
}
Expand All @@ -328,7 +328,7 @@ await _contentDefinitionManager.AlterPartDefinitionAsync(partDefinition.Name, pa
if (included != null && (bool)included)
{
fieldDefinition.Settings.Add(nameof(ElasticContentIndexSettings), JNode.FromObject(existingFieldSettings.ToObject<ElasticContentIndexSettings>()));
fieldDefinition.Settings[nameof(ElasticContentIndexSettings)] = JNode.FromObject(existingFieldSettings.ToObject<ElasticContentIndexSettings>());
}
}
}
Expand Down

0 comments on commit 701c07e

Please sign in to comment.