Example #1
0
        protected void AddDynamicField([CanBeNull] XmlNode node)
        {
            if (node?.Attributes?["name"] == null)
            {
                return;
            }

            var dynamicField = new SolrSchemaDynamicField();

            SetProperties(node, dynamicField);
            _solrSchemaDynamicFields.Add(dynamicField);
        }
        /// <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));
            }
        }