diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index c6895268ca..60821ba828 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -56,7 +56,7 @@ True - ..\packages\Examine.2.0.0-beta012\lib\net45\Examine.dll + ..\packages\Examine.2.0.0-beta013\lib\net45\Examine.dll True diff --git a/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs b/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs index b0070e8b58..c4b2f4a6ba 100644 --- a/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs +++ b/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs @@ -7,6 +7,7 @@ using Examine.LuceneEngine.Config; using Examine.LuceneEngine.Providers; using Examine.LuceneEngine.SearchCriteria; using Examine.SearchCriteria; +using Examine.Session; using Lucene.Net.Analysis.Standard; using Lucene.Net.Index; using Lucene.Net.Search; @@ -115,6 +116,7 @@ namespace Umbraco.Tests.UmbracoExamine { using (var luceneDir = new RAMDirectory()) using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, luceneDir)) + using (var session = new ThreadScopedIndexSession(indexer.SearcherContext)) { var searcher = indexer.GetSearcher(); @@ -131,6 +133,12 @@ namespace Umbraco.Tests.UmbracoExamine //ensure it's indexed indexer.ReIndexNode(node, IndexTypes.Media); + session.WaitForChanges(); + + //now ensure it's deleted + var results = searcher.Search(searcher.CreateSearchCriteria().Id(2112).Compile()); + Assert.AreEqual(1, results.Count()); + //change the parent node id to be the one it used to exist under var existingCriteria = indexer.IndexerData; indexer.IndexerData = new IndexCriteria(existingCriteria.StandardFields, existingCriteria.UserFields, existingCriteria.IncludeNodeTypes, existingCriteria.ExcludeNodeTypes, @@ -148,8 +156,10 @@ namespace Umbraco.Tests.UmbracoExamine indexer.IndexerData = new IndexCriteria(existingCriteria.StandardFields, existingCriteria.UserFields, existingCriteria.IncludeNodeTypes, existingCriteria.ExcludeNodeTypes, null); + session.WaitForChanges(); + //now ensure it's deleted - var results = searcher.Search(searcher.CreateSearchCriteria().Id(2112).Compile()); + results = searcher.Search(searcher.CreateSearchCriteria().Id(2112).Compile()); Assert.AreEqual(0, results.Count()); } } diff --git a/src/Umbraco.Tests/packages.config b/src/Umbraco.Tests/packages.config index e0fcc875aa..a4f996aad3 100644 --- a/src/Umbraco.Tests/packages.config +++ b/src/Umbraco.Tests/packages.config @@ -2,7 +2,7 @@ - + diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 71aded5e55..94b9fb5882 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -121,7 +121,7 @@ True - ..\packages\Examine.2.0.0-beta012\lib\net45\Examine.dll + ..\packages\Examine.2.0.0-beta013\lib\net45\Examine.dll True diff --git a/src/Umbraco.Web.UI/packages.config b/src/Umbraco.Web.UI/packages.config index 9990510cd3..67a8067584 100644 --- a/src/Umbraco.Web.UI/packages.config +++ b/src/Umbraco.Web.UI/packages.config @@ -3,7 +3,7 @@ - + diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index fe1e006701..c8d715911e 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -114,7 +114,7 @@ ..\packages\dotless.1.4.1.0\lib\dotless.Core.dll - ..\packages\Examine.2.0.0-beta012\lib\net45\Examine.dll + ..\packages\Examine.2.0.0-beta013\lib\net45\Examine.dll True diff --git a/src/Umbraco.Web/packages.config b/src/Umbraco.Web/packages.config index 227d0b7dfc..92b488bcfe 100644 --- a/src/Umbraco.Web/packages.config +++ b/src/Umbraco.Web/packages.config @@ -3,7 +3,7 @@ - + diff --git a/src/UmbracoExamine/BaseUmbracoIndexer.cs b/src/UmbracoExamine/BaseUmbracoIndexer.cs index b0d2af6762..a373cdecc8 100644 --- a/src/UmbracoExamine/BaseUmbracoIndexer.cs +++ b/src/UmbracoExamine/BaseUmbracoIndexer.cs @@ -34,17 +34,13 @@ namespace UmbracoExamine /// Used to store the path of a content object /// public const string IndexPathFieldName = "__Path"; - public const string NodeTypeAliasFieldName = "__NodeTypeAlias"; public const string IconFieldName = "__Icon"; - /// /// The prefix added to a field when it is duplicated in order to store the original raw value. /// public const string RawFieldPrefix = "__Raw_"; - #region Constructors - /// /// Default constructor /// @@ -52,6 +48,7 @@ namespace UmbracoExamine : base() { ProfilingLogger = ApplicationContext.Current.ProfilingLogger; + _configBased = true; } protected BaseUmbracoIndexer( @@ -67,8 +64,7 @@ namespace UmbracoExamine ProfilingLogger = profilingLogger; } - #endregion - + private bool _configBased = false; private readonly LocalTempStorageIndexer _localTempStorageIndexer = new LocalTempStorageIndexer(); /// @@ -98,9 +94,7 @@ namespace UmbracoExamine new StaticField( "nodeTypeAlias", FieldIndexTypes.ANALYZED, false, string.Empty), new StaticField( "path", FieldIndexTypes.NOT_ANALYZED, false, string.Empty) }; - - #region Properties - + protected ProfilingLogger ProfilingLogger { get; private set; } public bool UseTempStorage @@ -125,9 +119,7 @@ namespace UmbracoExamine /// /// the supported indexable types /// - protected abstract IEnumerable SupportedTypes { get; } - - #endregion + protected abstract IEnumerable SupportedTypes { get; } #region Initialize @@ -270,14 +262,21 @@ namespace UmbracoExamine /// Returns true if the Umbraco application is in a state that we can initialize the examine indexes /// /// + /// + /// This only affects indexers that are config file based, if an index was created via code then + /// this has no affect, it is assumed the index would not be created if it could not be initialized. + /// protected bool CanInitialize() { - //We need to check if we actually can initialize, if not then don't continue - if (ApplicationContext.Current == null - || !ApplicationContext.Current.IsConfigured - || !ApplicationContext.Current.DatabaseContext.IsDatabaseConfigured) + if (_configBased) { - return false; + //We need to check if we actually can initialize, if not then don't continue + if (ApplicationContext.Current == null + || ApplicationContext.Current.IsConfigured == false + || ApplicationContext.Current.DatabaseContext.IsDatabaseConfigured == false) + { + return false; + } } return true; @@ -441,15 +440,34 @@ namespace UmbracoExamine base.AddSingleNodeToIndex(node, type); } + protected override void OnTransformingIndexValues(TransformingIndexDataEventArgs e) + { + base.OnTransformingIndexValues(e); + + if (e.OriginalValues.ContainsKey("path")) + { + e.IndexItem.ValueSet.Values[IndexPathFieldName] = new List { e.OriginalValues["path"].First() }; + } + + ////adds the special node type alias property to the index + //fields.Add(NodeTypeAliasFieldName, allValuesForIndexing[NodeTypeAliasFieldName]); + + ////icon + //if (allValuesForIndexing[IconFieldName].IsNullOrWhiteSpace() == false) + //{ + // fields.Add(IconFieldName, allValuesForIndexing[IconFieldName]); + //} + + //return fields; + } + /// /// Override this method to strip all html from all user fields before raising the event, then after the event /// ensure our special Path field is added to the collection /// /// - protected override void OnGatheringNodeData(IndexingNodeDataEventArgs e) { - //strip html of all users fields if we detect it has HTML in it. //if that is the case, we'll create a duplicate 'raw' copy of it so that we can return //the value of the field 'as-is'. @@ -505,31 +523,6 @@ namespace UmbracoExamine () => fieldName, () => indexSetName, () => nodeId); } - /// - /// Overridden to add the path property to the special fields to index - /// - /// - /// - protected override Dictionary GetSpecialFieldsToIndex(Dictionary allValuesForIndexing) - { - var fields = base.GetSpecialFieldsToIndex(allValuesForIndexing); - - //adds the special path property to the index - fields.Add(IndexPathFieldName, allValuesForIndexing[IndexPathFieldName]); - - //adds the special node type alias property to the index - fields.Add(NodeTypeAliasFieldName, allValuesForIndexing[NodeTypeAliasFieldName]); - - //icon - if (allValuesForIndexing[IconFieldName].IsNullOrWhiteSpace() == false) - { - fields.Add(IconFieldName, allValuesForIndexing[IconFieldName]); - } - - return fields; - - } - /// /// return the index policy for the field name passed in, if not found, return normal /// diff --git a/src/UmbracoExamine/UmbracoContentValueSetValidator.cs b/src/UmbracoExamine/UmbracoContentValueSetValidator.cs index e8147eddcd..5b38bc81e8 100644 --- a/src/UmbracoExamine/UmbracoContentValueSetValidator.cs +++ b/src/UmbracoExamine/UmbracoContentValueSetValidator.cs @@ -21,7 +21,10 @@ namespace UmbracoExamine public bool Validate(ValueSet valueSet) { - var path = valueSet.Values[BaseUmbracoIndexer.IndexPathFieldName]; + //must have a 'path' + if (valueSet.Values.ContainsKey("path") == false) return false; + + var path = valueSet.Values["path"]; // Test for access if we're only indexing published content // return nothing if we're not supporting protected content and it is protected, and we're not supporting unpublished content if (_options.SupportUnpublishedContent == false diff --git a/src/UmbracoExamine/UmbracoExamine.csproj b/src/UmbracoExamine/UmbracoExamine.csproj index 9dfec735f3..5b82aad568 100644 --- a/src/UmbracoExamine/UmbracoExamine.csproj +++ b/src/UmbracoExamine/UmbracoExamine.csproj @@ -83,7 +83,7 @@ - ..\packages\Examine.2.0.0-beta012\lib\net45\Examine.dll + ..\packages\Examine.2.0.0-beta013\lib\net45\Examine.dll True diff --git a/src/UmbracoExamine/UmbracoMemberIndexer.cs b/src/UmbracoExamine/UmbracoMemberIndexer.cs index 665af9912a..f8f8a43959 100644 --- a/src/UmbracoExamine/UmbracoMemberIndexer.cs +++ b/src/UmbracoExamine/UmbracoMemberIndexer.cs @@ -165,16 +165,13 @@ namespace UmbracoExamine var serializer = new EntityXmlSerializer(); return members.Select(member => serializer.Serialize(_dataTypeService, member)); } - - protected override Dictionary GetSpecialFieldsToIndex(Dictionary allValuesForIndexing) + + protected override void OnTransformingIndexValues(TransformingIndexDataEventArgs e) { - var fields = base.GetSpecialFieldsToIndex(allValuesForIndexing); + base.OnTransformingIndexValues(e); //adds the special path property to the index - fields.Add("__key", allValuesForIndexing["__key"]); - - return fields; - + //fields.Add("__key", allValuesForIndexing["__key"]); } /// diff --git a/src/UmbracoExamine/packages.config b/src/UmbracoExamine/packages.config index 6834e181ac..6ffe666e13 100644 --- a/src/UmbracoExamine/packages.config +++ b/src/UmbracoExamine/packages.config @@ -1,6 +1,6 @@  - +