diff --git a/build/NuSpecs/UmbracoCms.Web.nuspec b/build/NuSpecs/UmbracoCms.Web.nuspec index 1693e0a7d1..d36c4a240a 100644 --- a/build/NuSpecs/UmbracoCms.Web.nuspec +++ b/build/NuSpecs/UmbracoCms.Web.nuspec @@ -25,7 +25,7 @@ - + diff --git a/src/Umbraco.Examine/Umbraco.Examine.csproj b/src/Umbraco.Examine/Umbraco.Examine.csproj index aa00f29f4a..56e9b1a928 100644 --- a/src/Umbraco.Examine/Umbraco.Examine.csproj +++ b/src/Umbraco.Examine/Umbraco.Examine.csproj @@ -48,7 +48,7 @@ - + @@ -90,6 +90,7 @@ + Properties\SolutionInfo.cs diff --git a/src/Umbraco.Examine/UmbracoContentIndex.cs b/src/Umbraco.Examine/UmbracoContentIndex.cs index 3231511936..9134c691f4 100644 --- a/src/Umbraco.Examine/UmbracoContentIndex.cs +++ b/src/Umbraco.Examine/UmbracoContentIndex.cs @@ -18,45 +18,6 @@ using Examine.LuceneEngine; namespace Umbraco.Examine { - /// - /// Custom allowing dynamic creation of - /// - public class UmbracoFieldDefinitionCollection : FieldDefinitionCollection - { - - public UmbracoFieldDefinitionCollection() - : base(UmbracoExamineIndex.UmbracoIndexFieldDefinitions) - { - } - - ///// - ///// Overridden to dynamically add field definitions for culture variations - ///// - ///// - ///// - ///// - //public override bool TryGetValue(string fieldName, out FieldDefinition fieldDefinition) - //{ - // var result = base.TryGetValue(fieldName, out fieldDefinition); - // if (result) return true; - - // //if the fieldName is not suffixed with _iso-Code - // var underscoreIndex = fieldName.LastIndexOf('_'); - // if (underscoreIndex == -1) return false; - - - - // var isoCode = fieldName.Substring(underscoreIndex); - // if (isoCode.Length < 6) return false; //invalid isoCode - - // var hyphenIndex = isoCode.IndexOf('-'); - // if (hyphenIndex != 3) return false; //invalid isoCode - - // //we'll assume this is a valid isoCode - - //} - } - /// /// An indexer for Umbraco content and media /// @@ -161,7 +122,7 @@ namespace Umbraco.Examine //anywhere else in this class Current.Services.PublicAccessService, parentId, - ConfigIndexCriteria.IncludeItemTypes, ConfigIndexCriteria.ExcludeItemTypes); + ConfigIndexCriteria?.IncludeItemTypes, ConfigIndexCriteria?.ExcludeItemTypes); PublishedValuesOnly = supportUnpublished; } diff --git a/src/Umbraco.Examine/UmbracoExamineIndex.cs b/src/Umbraco.Examine/UmbracoExamineIndex.cs index 9cf4d05c75..3a7a21bdb3 100644 --- a/src/Umbraco.Examine/UmbracoExamineIndex.cs +++ b/src/Umbraco.Examine/UmbracoExamineIndex.cs @@ -20,8 +20,7 @@ namespace Umbraco.Examine { /// - /// An abstract provider containing the basic functionality to be able to query against - /// Umbraco data. + /// An abstract provider containing the basic functionality to be able to query against Umbraco data. /// public abstract class UmbracoExamineIndex : LuceneIndex, IUmbracoIndex, IIndexDiagnostics { @@ -53,6 +52,7 @@ namespace Umbraco.Examine { ProfilingLogger = Current.ProfilingLogger; _configBased = true; + _diagnostics = new UmbracoExamineIndexDiagnostics(this, ProfilingLogger.Logger); } /// @@ -120,26 +120,6 @@ namespace Umbraco.Examine protected ProfilingLogger ProfilingLogger { get; } - /// - /// Overridden to ensure that the umbraco system field definitions are in place - /// - /// - /// - protected override FieldValueTypeCollection CreateFieldValueTypes(IReadOnlyDictionary indexValueTypesFactory = null) - { - //if config based then ensure the value types else it's assumed these were passed in via ctor - if (_configBased) - { - foreach (var field in UmbracoIndexFieldDefinitions) - { - FieldDefinitionCollection.TryAdd(field); - } - } - - - return base.CreateFieldValueTypes(indexValueTypesFactory); - } - /// /// When set to true Umbraco will keep the index in sync with Umbraco data automatically /// @@ -174,12 +154,15 @@ namespace Umbraco.Examine EnableDefaultEventHandler = enabled; } - //Need to check if the index set or IndexerData is specified... - if (config["indexSet"] == null && FieldDefinitionCollection.Count == 0) + //this is config based, so add the default definitions + foreach (var field in UmbracoIndexFieldDefinitions) { - //if we don't have either, then we'll try to set the index set by naming conventions - var found = false; + FieldDefinitionCollection.TryAdd(field); + } + //Need to check if the index set is specified... + if (config["indexSet"] == null) + { var possibleSuffixes = new[] {"Index", "Indexer"}; foreach (var suffix in possibleSuffixes) { @@ -200,36 +183,29 @@ namespace Umbraco.Examine ConfigIndexCriteria = CreateFieldDefinitionsFromConfig(indexSet); foreach (var fieldDefinition in ConfigIndexCriteria.StandardFields.Union(ConfigIndexCriteria.UserFields)) { - FieldDefinitionCollection.TryAdd(fieldDefinition); + //replace any existing or add + FieldDefinitionCollection.AddOrUpdate(fieldDefinition); } - found = true; break; } - - if (!found) - throw new ArgumentNullException("indexSet on LuceneExamineIndexer provider has not been set in configuration and/or the IndexerData property has not been explicitly set"); - } - else if (config["indexSet"] != null) + else { //if an index set is specified, ensure it exists and initialize the indexer based on the set if (IndexSets.Instance.Sets[config["indexSet"]] == null) - { throw new ArgumentException("The indexSet specified for the LuceneExamineIndexer provider does not exist"); - } - else + + IndexSetName = config["indexSet"]; + + var indexSet = IndexSets.Instance.Sets[IndexSetName]; + + //get the index criteria and ensure folder + ConfigIndexCriteria = CreateFieldDefinitionsFromConfig(indexSet); + foreach (var fieldDefinition in ConfigIndexCriteria.StandardFields.Union(ConfigIndexCriteria.UserFields)) { - IndexSetName = config["indexSet"]; - - var indexSet = IndexSets.Instance.Sets[IndexSetName]; - - //get the index criteria and ensure folder - ConfigIndexCriteria = CreateFieldDefinitionsFromConfig(indexSet); - foreach (var fieldDefinition in ConfigIndexCriteria.StandardFields.Union(ConfigIndexCriteria.UserFields)) - { - FieldDefinitionCollection.TryAdd(fieldDefinition); - } + //replace any existing or add + FieldDefinitionCollection.AddOrUpdate(fieldDefinition); } } diff --git a/src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs b/src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs new file mode 100644 index 0000000000..ce59501046 --- /dev/null +++ b/src/Umbraco.Examine/UmbracoFieldDefinitionCollection.cs @@ -0,0 +1,43 @@ +using Examine; + +namespace Umbraco.Examine +{ + /// + /// Custom allowing dynamic creation of + /// + public class UmbracoFieldDefinitionCollection : FieldDefinitionCollection + { + + public UmbracoFieldDefinitionCollection() + : base(UmbracoExamineIndex.UmbracoIndexFieldDefinitions) + { + } + + ///// + ///// Overridden to dynamically add field definitions for culture variations + ///// + ///// + ///// + ///// + //public override bool TryGetValue(string fieldName, out FieldDefinition fieldDefinition) + //{ + // var result = base.TryGetValue(fieldName, out fieldDefinition); + // if (result) return true; + + // //if the fieldName is not suffixed with _iso-Code + // var underscoreIndex = fieldName.LastIndexOf('_'); + // if (underscoreIndex == -1) return false; + + + + // var isoCode = fieldName.Substring(underscoreIndex); + // if (isoCode.Length < 6) return false; //invalid isoCode + + // var hyphenIndex = isoCode.IndexOf('-'); + // if (hyphenIndex != 3) return false; //invalid isoCode + + // //we'll assume this is a valid isoCode + + //} + } +} \ No newline at end of file diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 4112be45ca..38c049f7aa 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -77,7 +77,7 @@ - + 1.8.9 diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index cde23b0df6..88155846d7 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -88,7 +88,7 @@ - + diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 54b5a025bf..9a96acbd8c 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -62,7 +62,7 @@ - + 2.6.2.25