/// <summary> /// Returns remove commands for only specified fields. Used when /// removeAllFields is false. /// </summary> /// <returns></returns> public IEnumerable <XElement> GetRemoveSurplusFields() { // Note: There is no way to update a copy-field and adding a copy field // twice creates duplicates. Therefore all copy-fields always has to be // removed before re-adding them. foreach (var field in _solrSolrSchemaConfiguration.RemoveCopyFields) { yield return(field.SerializeDeleteCommand(_solrSchema)); } foreach (var solrCopyField in _solrSchema.SolrCopyFields) // Those will be re-added later { var d = new SolrSchemaCopyField { Source = solrCopyField.Source, Destination = solrCopyField.Destination }; yield return(d.SerializeDeleteCommand(_solrSchema)); } foreach (var field in _solrSolrSchemaConfiguration.RemoveDynamicFields) { yield return(field.SerializeDeleteCommand(_solrSchema)); } foreach (var field in _solrSolrSchemaConfiguration.RemoveFields) { yield return(field.SerializeDeleteCommand(_solrSchema)); } }
/// <summary> /// Returns remove commands for all existing fields, equal to the default /// Sitecore implementation /// </summary> /// <returns></returns> public IEnumerable <XElement> GetRemoveAllFields() { foreach (var solrCopyField in _solrSchema.SolrCopyFields) { var d = new SolrSchemaCopyField { Source = solrCopyField.Source, Destination = solrCopyField.Destination }; yield return(d.SerializeDeleteCommand(_solrSchema)); } foreach (var solrDynamicField in _solrSchema.SolrDynamicFields .Where(s => _solrSolrSchemaConfiguration.DynamicFields.All(f => f.Name != s.Name))) { var d = new SolrSchemaDynamicField(solrDynamicField.Name); yield return(d.SerializeDeleteCommand(_solrSchema)); } foreach (var solrField in _solrSchema.SolrFields .Where(s => _solrSolrSchemaConfiguration.Fields.All(f => f.Name != s.Name))) { var d = new SolrSchemaField(solrField.Name); yield return(d.SerializeDeleteCommand(_solrSchema)); } }