diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 273915d1a3..21aefb9023 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-beta014\lib\net45\Examine.dll + ..\packages\Examine.2.0.0-beta019\lib\net45\Examine.dll True @@ -544,7 +544,7 @@ - + diff --git a/src/Umbraco.Tests/UmbracoExamine/EventsTest.cs b/src/Umbraco.Tests/UmbracoExamine/EventsTest.cs index d3fa3ada39..e9e7d4a700 100644 --- a/src/Umbraco.Tests/UmbracoExamine/EventsTest.cs +++ b/src/Umbraco.Tests/UmbracoExamine/EventsTest.cs @@ -40,7 +40,7 @@ namespace Umbraco.Tests.UmbracoExamine } - private readonly TestContentService _contentService = new TestContentService(); + private readonly ExamineDemoDataContentService _contentService = new ExamineDemoDataContentService(); private static UmbracoContentIndexer _indexer; private Lucene.Net.Store.Directory _luceneDir; diff --git a/src/Umbraco.Tests/UmbracoExamine/ExamineDemoDataContentService.cs b/src/Umbraco.Tests/UmbracoExamine/ExamineDemoDataContentService.cs new file mode 100644 index 0000000000..94d388aed3 --- /dev/null +++ b/src/Umbraco.Tests/UmbracoExamine/ExamineDemoDataContentService.cs @@ -0,0 +1,64 @@ +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; +using System.Xml.Linq; +using System.Xml.XPath; +using Umbraco.Core.Persistence; +using Umbraco.Core.Persistence.Repositories; +using UmbracoExamine; + +namespace Umbraco.Tests.UmbracoExamine +{ + //TODO: This is ultra hack and still left over from legacy but still works for testing atm + public class ExamineDemoDataContentService + { + public const int ProtectedNode = 1142; + + public ExamineDemoDataContentService(string contentXml = null) + { + if (contentXml == null) + { + contentXml = TestFiles.umbraco; + } + _xContent = XDocument.Parse(contentXml); + } + + /// + /// Return the XDocument containing the xml from the umbraco.config xml file + /// + /// + /// + /// + /// This is no different in the test suite as published content + /// + public XDocument GetLatestContentByXPath(string xpath) + { + var xdoc = XDocument.Parse(""); + xdoc.Root.Add(_xContent.XPathSelectElements(xpath)); + + return xdoc; + } + + /// + /// Return the XDocument containing the xml from the umbraco.config xml file + /// + /// + /// + public XDocument GetPublishedContentByXPath(string xpath) + { + return GetContentByXPath(xpath, _xContent); + } + + private XDocument GetContentByXPath(string xpath, XDocument content) + { + var xdoc = XDocument.Parse(""); + xdoc.Root.Add(content.XPathSelectElements(xpath)); + + return xdoc; + } + + private readonly XDocument _xContent; + + + } +} \ No newline at end of file diff --git a/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs b/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs index 6be64990a6..05eacf6cc2 100644 --- a/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs +++ b/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs @@ -38,7 +38,37 @@ namespace Umbraco.Tests.UmbracoExamine { if (contentService == null) { - contentService = Mock.Of(); + long totalRecs; + + var demoData = new ExamineDemoDataContentService(); + + var allRecs = demoData.GetLatestContentByXPath("//*[@isDoc]") + .Root + .Elements() + .Select(x => Mock.Of( + m => + m.Id == (int)x.Attribute("id") && + m.ParentId == (int)x.Attribute("parentID") && + m.Level == (int)x.Attribute("level") && + m.CreatorId == 0 && + m.SortOrder == (int)x.Attribute("sortOrder") && + m.CreateDate == (DateTime)x.Attribute("createDate") && + m.UpdateDate == (DateTime)x.Attribute("updateDate") && + m.Name == (string)x.Attribute("nodeName") && + m.Path == (string)x.Attribute("path") && + m.Properties == new PropertyCollection() && + m.ContentType == Mock.Of(mt => + mt.Icon == "test" && + mt.Alias == x.Name.LocalName && + mt.Id == (int)x.Attribute("nodeType")))) + .ToArray(); + + + contentService = Mock.Of( + x => x.GetPagedDescendants( + It.IsAny(), It.IsAny(), It.IsAny(), out totalRecs, It.IsAny(), It.IsAny(), It.IsAny()) + == + allRecs); } if (userService == null) { diff --git a/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs b/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs index 46633c2756..74a134e2f5 100644 --- a/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs +++ b/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs @@ -29,18 +29,43 @@ namespace Umbraco.Tests.UmbracoExamine public class IndexTest : ExamineBaseTest { - ///// - /// - /// Check that the node signalled as protected in the content service is not present in the index. - /// - [Test] + [Test] + public void Rebuild_Index() + { + + using (var luceneDir = new RAMDirectory()) + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, luceneDir)) + using (var session = new ThreadScopedIndexSession(indexer.SearcherContext)) + { + var searcher = indexer.GetSearcher(); + + //create the whole thing + indexer.RebuildIndex(); + session.WaitForChanges(); + + var result = searcher.Find(searcher.CreateCriteria().All().Compile()); + + Assert.AreEqual(29, result.TotalItemCount); + } + } + + ///// + /// + /// Check that the node signalled as protected in the content service is not present in the index. + /// + [Test] public void Index_Protected_Content_Not_Indexed() { using (var luceneDir = new RAMDirectory()) using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, luceneDir)) + using (var session = new ThreadScopedIndexSession(indexer.SearcherContext)) using (var searcher = indexer.GetSearcher().GetSearcher()) { + //create the whole thing + indexer.RebuildIndex(); + session.WaitForChanges(); + var protectedQuery = new BooleanQuery(); protectedQuery.Add( new BooleanClause( @@ -49,11 +74,11 @@ namespace Umbraco.Tests.UmbracoExamine protectedQuery.Add( new BooleanClause( - new TermQuery(new Term(LuceneIndexer.IndexNodeIdFieldName, TestContentService.ProtectedNode.ToString())), + new TermQuery(new Term(LuceneIndexer.IndexNodeIdFieldName, ExamineDemoDataContentService.ProtectedNode.ToString())), Occur.MUST)); var collector = TopScoreDocCollector.Create(100, true); - + searcher.Search(protectedQuery, collector); Assert.AreEqual(0, collector.TotalHits, "Protected node should not be indexed"); @@ -65,22 +90,13 @@ namespace Umbraco.Tests.UmbracoExamine public void Index_Move_Media_From_Non_Indexable_To_Indexable_ParentID() { using (var luceneDir = new RAMDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, luceneDir)) + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, luceneDir, + //make parent id 1116 + options: new UmbracoContentIndexerOptions(false, false, 1116))) + using (var session = new ThreadScopedIndexSession(indexer.SearcherContext)) { var searcher = indexer.GetSearcher(); - //change parent id to 1116 - var existingCriteria = indexer.IndexerData; - indexer.IndexerData = new IndexCriteria(existingCriteria.StandardFields, existingCriteria.UserFields, existingCriteria.IncludeNodeTypes, existingCriteria.ExcludeNodeTypes, - 1116); - - //rebuild so it excludes children unless they are under 1116 - indexer.RebuildIndex(); - - //ensure that node 2112 doesn't exist - var results = searcher.Search(searcher.CreateSearchCriteria().Id(2112).Compile()); - Assert.AreEqual(0, results.Count()); - //get a node from the data repo (this one exists underneath 2222) var node = _mediaService.GetLatestMediaByXpath("//*[string-length(@id)>0 and number(@id)>0]") .Root @@ -91,6 +107,15 @@ namespace Umbraco.Tests.UmbracoExamine var currPath = (string)node.Attribute("path"); //should be : -1,1111,2222,2112 Assert.AreEqual("-1,1111,2222,2112", currPath); + //ensure it's indexed + indexer.ReIndexNode(node, IndexTypes.Media); + + session.WaitForChanges(); + + //it will not exist because it exists under 2222 + var results = searcher.Search(searcher.CreateSearchCriteria().Id(2112).Compile()); + Assert.AreEqual(0, results.Count()); + //now mimic moving 2112 to 1116 //node.SetAttributeValue("path", currPath.Replace("2222", "1116")); node.SetAttributeValue("path", "-1,1116,2112"); @@ -99,14 +124,11 @@ namespace Umbraco.Tests.UmbracoExamine //now reindex the node, this should first delete it and then WILL add it because of the parent id constraint indexer.ReIndexNode(node, IndexTypes.Media); - //RESET the parent id - existingCriteria = ((IndexCriteria)indexer.IndexerData); - indexer.IndexerData = new IndexCriteria(existingCriteria.StandardFields, existingCriteria.UserFields, existingCriteria.IncludeNodeTypes, existingCriteria.ExcludeNodeTypes, - null); + session.WaitForChanges(); - //now ensure it's deleted - var newResults = searcher.Search(searcher.CreateSearchCriteria().Id(2112).Compile()); - Assert.AreEqual(1, newResults.Count()); + //now ensure it exists + results = searcher.Search(searcher.CreateSearchCriteria().Id(2112).Compile()); + Assert.AreEqual(1, results.Count()); } } @@ -166,42 +188,40 @@ 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(); - - var s = searcher.GetSearcher(); - - //first delete all 'Content' (not media). This is done by directly manipulating the index with the Lucene API, not examine! + //create the whole thing + indexer.RebuildIndex(); + session.WaitForChanges(); - var contentTerm = new Term(LuceneIndexer.IndexTypeFieldName, IndexTypes.Content); - var writer = indexer.GetIndexWriter(); - writer.DeleteDocuments(contentTerm); - writer.Commit(); - - //make sure the content is gone. This is done with lucene APIs, not examine! - var collector = TopScoreDocCollector.Create(100, true); - var query = new TermQuery(contentTerm); - s = (IndexSearcher)searcher.GetSearcher(); //make sure the searcher is up do date. - s.Search(query, collector); - Assert.AreEqual(0, collector.TotalHits); + var result = searcher.Find(searcher.CreateCriteria().Field(LuceneIndexer.IndexTypeFieldName, IndexTypes.Content).Compile()); + Assert.AreEqual(21, result.TotalItemCount); + + //delete all content + foreach (var r in result) + { + indexer.DeleteFromIndex(r.LongId); + } + session.WaitForChanges(); + + //ensure it's all gone + result = searcher.Find(searcher.CreateCriteria().Field(LuceneIndexer.IndexTypeFieldName, IndexTypes.Content).Compile()); + Assert.AreEqual(0, result.TotalItemCount); //call our indexing methods indexer.IndexAll(IndexTypes.Content); - collector = TopScoreDocCollector.Create(100, true); - s = searcher.GetSearcher(); //make sure the searcher is up do date. - s.Search(query, collector); - //var ids = new List(); - //for (var i = 0; i < collector.Count;i++) - //{ - // ids.Add(s.Doc(collector.GetDocId(i)).GetValues("__NodeId")[0]); - //} - Assert.AreEqual(20, collector.TotalHits); + session.WaitForChanges(); + + result = searcher.Find(searcher.CreateCriteria().Field(LuceneIndexer.IndexTypeFieldName, IndexTypes.Content).Compile()); + Assert.AreEqual(21, result.TotalItemCount); + } - - } + + } /// /// This will delete an item from the index and ensure that all children of the node are deleted too! @@ -211,14 +231,21 @@ 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(); + //create the whole thing + indexer.RebuildIndex(); + session.WaitForChanges(); + //now delete a node that has children indexer.DeleteFromIndex(1140.ToString()); //this node had children: 1141 & 1142, let's ensure they are also removed + session.WaitForChanges(); + var results = searcher.Search(searcher.CreateSearchCriteria().Id(1141).Compile()); Assert.AreEqual(0, results.Count()); diff --git a/src/Umbraco.Tests/UmbracoExamine/TestContentService.cs b/src/Umbraco.Tests/UmbracoExamine/TestContentService.cs deleted file mode 100644 index 3eb846b00c..0000000000 --- a/src/Umbraco.Tests/UmbracoExamine/TestContentService.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text.RegularExpressions; -using System.Xml.Linq; -using System.Xml.XPath; -using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Repositories; -using UmbracoExamine; - -namespace Umbraco.Tests.UmbracoExamine -{ - /// - /// A mock data service used to return content from the XML data file created with CWS - /// - public class TestContentService - { - public const int ProtectedNode = 1142; - - public TestContentService(string contentXml = null, string mediaXml = null) - { - if (contentXml == null) - { - contentXml = TestFiles.umbraco; - } - if (mediaXml == null) - { - mediaXml = TestFiles.media; - } - _xContent = XDocument.Parse(contentXml); - _xMedia = XDocument.Parse(mediaXml); - } - - #region IContentService Members - - /// - /// Return the XDocument containing the xml from the umbraco.config xml file - /// - /// - /// - /// - /// This is no different in the test suite as published content - /// - public XDocument GetLatestContentByXPath(string xpath) - { - var xdoc = XDocument.Parse(""); - xdoc.Root.Add(_xContent.XPathSelectElements(xpath)); - - return xdoc; - } - - /// - /// Return the XDocument containing the xml from the umbraco.config xml file - /// - /// - /// - public XDocument GetPublishedContentByXPath(string xpath) - { - return GetContentByXPath(xpath, _xContent); - } - - private XDocument GetContentByXPath(string xpath, XDocument content) - { - var xdoc = XDocument.Parse(""); - xdoc.Root.Add(content.XPathSelectElements(xpath)); - - return xdoc; - } - - public string StripHtml(string value) - { - const string pattern = @"<(.|\n)*?>"; - return Regex.Replace(value, pattern, string.Empty); - } - - public bool IsProtected(int nodeId, string path) - { - // single node is marked as protected for test indexer - // hierarchy is not important for this test - return nodeId == ProtectedNode; - } - - private List _userPropNames; - public IEnumerable GetAllUserPropertyNames() - { - if (_userPropNames == null) - { - var xpath = "//*[count(@id)>0 and @id != -1]"; - _userPropNames = GetPublishedContentByXPath(xpath) - .Root - .Elements() //each page - .SelectMany(x => x.Elements().Where(e => e.Attribute("id") == null)) //each page property (no @id) - .Select(x => x.Name.LocalName) //the name of the property - .Distinct() - .Union(GetContentByXPath(xpath, _xMedia) - .Root - .Elements() //each page - .SelectMany(x => x.Elements().Where(e => e.Attribute("id") == null)) //each page property (no @id) - .Select(x => (string)x.Attribute("alias")) //the name of the property NOTE: We are using the legacy XML here. - .Distinct()).ToList(); - } - return _userPropNames; - } - - private List _sysPropNames; - public IEnumerable GetAllSystemPropertyNames() - { - if (_sysPropNames == null) - { - _sysPropNames = UmbracoContentIndexer.IndexFieldPolicies.Select(x => x.Name).ToList(); - } - return _sysPropNames; - } - - #endregion - - private readonly XDocument _xContent; - private readonly XDocument _xMedia; - - - - - - - } -} \ No newline at end of file diff --git a/src/Umbraco.Tests/packages.config b/src/Umbraco.Tests/packages.config index 636ba243f9..5901df76d5 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 f5f41339d5..450767bfef 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-beta014\lib\net45\Examine.dll + ..\packages\Examine.2.0.0-beta019\lib\net45\Examine.dll True diff --git a/src/Umbraco.Web.UI/packages.config b/src/Umbraco.Web.UI/packages.config index af0ac65e86..4c7d260db2 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 00d4cdb813..6d1bd1d2a2 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-beta014\lib\net45\Examine.dll + ..\packages\Examine.2.0.0-beta019\lib\net45\Examine.dll True diff --git a/src/Umbraco.Web/packages.config b/src/Umbraco.Web/packages.config index 7f6230500c..b39d1537e9 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 9ac781acce..aeb5c9f06c 100644 --- a/src/UmbracoExamine/BaseUmbracoIndexer.cs +++ b/src/UmbracoExamine/BaseUmbracoIndexer.cs @@ -52,10 +52,10 @@ namespace UmbracoExamine } protected BaseUmbracoIndexer( - IEnumerable fieldDefinitions, - Directory luceneDirectory, - Analyzer defaultAnalyzer, - ProfilingLogger profilingLogger, + IEnumerable fieldDefinitions, + Directory luceneDirectory, + Analyzer defaultAnalyzer, + ProfilingLogger profilingLogger, IValueSetValidator validator = null, FacetConfiguration facetConfiguration = null, IDictionary> indexValueTypes = null) : base(fieldDefinitions, luceneDirectory, defaultAnalyzer, validator, facetConfiguration, indexValueTypes) @@ -97,6 +97,23 @@ namespace UmbracoExamine protected ProfilingLogger ProfilingLogger { get; private set; } + /// + /// Overridden to ensure that + /// + /// + /// + protected override IEnumerable InitializeFieldDefinitions(IEnumerable originalDefinitions) + { + var fd = base.InitializeFieldDefinitions(originalDefinitions).ToList(); + fd.AddRange(new[] + { + new FieldDefinition(IndexPathFieldName, FieldDefinitionTypes.Raw), + new FieldDefinition(NodeTypeAliasFieldName, FieldDefinitionTypes.Raw), + new FieldDefinition(IconFieldName, FieldDefinitionTypes.Raw) + }); + return fd; + } + public bool UseTempStorage { get { return _localTempStorageIndexer.LuceneDirectory != null; } diff --git a/src/UmbracoExamine/UmbracoContentIndexer.cs b/src/UmbracoExamine/UmbracoContentIndexer.cs index 7bc2a3eb6b..7632a86063 100644 --- a/src/UmbracoExamine/UmbracoContentIndexer.cs +++ b/src/UmbracoExamine/UmbracoContentIndexer.cs @@ -76,6 +76,11 @@ namespace UmbracoExamine SupportProtectedContent = options.SupportProtectedContent; SupportUnpublishedContent = options.SupportUnpublishedContent; + ParentId = options.ParentId; + //backward compat hack: + IndexerData = new IndexCriteria(Enumerable.Empty(), Enumerable.Empty(), Enumerable.Empty(), Enumerable.Empty(), + //hack to set the parent Id for backwards compat, when using this ctor the IndexerData will (should) always be null + options.ParentId); ContentService = contentService; MediaService = mediaService; @@ -151,6 +156,11 @@ namespace UmbracoExamine /// public bool SupportUnpublishedContent { get; protected set; } + /// + /// If set this will filter the content items allowed to be indexed + /// + public int? ParentId { get; protected set; } + protected override IEnumerable SupportedTypes { get @@ -176,29 +186,28 @@ namespace UmbracoExamine /// ID of the node to delete public override void DeleteFromIndex(string nodeId) { - throw new NotImplementedException("Fix DeleteFromIndex!"); + //find all descendants based on path + var descendantPath = string.Format(@"\-1\,*{0}\,*", nodeId); + var rawQuery = string.Format("{0}:{1}", IndexPathFieldName, descendantPath); + var searcher = GetSearcher(); + var c = searcher.CreateSearchCriteria(); + var filtered = c.RawQuery(rawQuery); + var results = searcher.Search(filtered); - ////find all descendants based on path - //var descendantPath = string.Format(@"\-1\,*{0}\,*", nodeId); - //var rawQuery = string.Format("{0}:{1}", IndexPathFieldName, descendantPath); - //var c = InternalSearcher.CreateSearchCriteria(); - //var filtered = c.RawQuery(rawQuery); - //var results = InternalSearcher.Search(filtered); + ProfilingLogger.Logger.Debug(GetType(), string.Format("DeleteFromIndex with query: {0} (found {1} results)", rawQuery, results.TotalItemCount)); - //DataService.LogService.AddVerboseLog(int.Parse(nodeId), string.Format("DeleteFromIndex with query: {0} (found {1} results)", rawQuery, results.Count())); + //need to create a delete queue item for each one found + foreach (var r in results) + { + EnqueueIndexOperation(new IndexOperation() + { + Operation = IndexOperationType.Delete, + Item = new IndexItem(null, "", r.Id.ToString()) + }); + //SaveDeleteIndexQueueItem(new KeyValuePair(IndexNodeIdFieldName, r.Id.ToString())); + } - ////need to create a delete queue item for each one found - //foreach (var r in results) - //{ - // EnqueueIndexOperation(new IndexOperation() - // { - // Operation = IndexOperationType.Delete, - // Item = new IndexItem(null, "", r.Id.ToString()) - // }); - // //SaveDeleteIndexQueueItem(new KeyValuePair(IndexNodeIdFieldName, r.Id.ToString())); - //} - - //base.DeleteFromIndex(nodeId); + base.DeleteFromIndex(nodeId); } #endregion @@ -213,47 +222,40 @@ namespace UmbracoExamine switch (type) { case IndexTypes.Content: - if (this.SupportUnpublishedContent == false) + + var contentParentId = -1; + if (IndexerData.ParentNodeId.HasValue && IndexerData.ParentNodeId.Value > 0) { - //TODO: Need to deal with Published Content here - - throw new NotImplementedException("NEED TO FIX PUBLISHED CONTENT INDEXING"); - - //use the base implementation which will use the published XML cache to perform the lookups - //base.PerformIndexAll(type); + contentParentId = IndexerData.ParentNodeId.Value; } - else + IContent[] content; + + do { - var contentParentId = -1; - if (IndexerData.ParentNodeId.HasValue && IndexerData.ParentNodeId.Value > 0) + long total; + + var descendants = SupportUnpublishedContent == false + ? ContentService.GetPagedDescendants(contentParentId, pageIndex, pageSize, out total, filter: "published") + : ContentService.GetPagedDescendants(contentParentId, pageIndex, pageSize, out total); + + //if specific types are declared we need to post filter them + //TODO: Update the service layer to join the cmsContentType table so we can query by content type too + if (IndexerData.IncludeNodeTypes.Any()) { - contentParentId = IndexerData.ParentNodeId.Value; + content = descendants.Where(x => IndexerData.IncludeNodeTypes.Contains(x.ContentType.Alias)).ToArray(); } - IContent[] content; - - do + else { - long total; - var descendants = ContentService.GetPagedDescendants(contentParentId, pageIndex, pageSize, out total); + content = descendants.ToArray(); + } - //if specific types are declared we need to post filter them - //TODO: Update the service layer to join the cmsContentType table so we can query by content type too - if (IndexerData.IncludeNodeTypes.Any()) - { - content = descendants.Where(x => IndexerData.IncludeNodeTypes.Contains(x.ContentType.Alias)).ToArray(); - } - else - { - content = descendants.ToArray(); - } - - AddNodesToIndex(GetSerializedContent(content), type); - pageIndex++; + AddNodesToIndex(GetSerializedContent(content), type); + pageIndex++; - } while (content.Length == pageSize); + } while (content.Length == pageSize); - } + break; case IndexTypes.Media: diff --git a/src/UmbracoExamine/UmbracoExamine.csproj b/src/UmbracoExamine/UmbracoExamine.csproj index 9ac6ebbe3e..764a3d2c6d 100644 --- a/src/UmbracoExamine/UmbracoExamine.csproj +++ b/src/UmbracoExamine/UmbracoExamine.csproj @@ -83,7 +83,7 @@ - ..\packages\Examine.2.0.0-beta014\lib\net45\Examine.dll + ..\packages\Examine.2.0.0-beta019\lib\net45\Examine.dll True diff --git a/src/UmbracoExamine/packages.config b/src/UmbracoExamine/packages.config index 31be3468d2..6431190dac 100644 --- a/src/UmbracoExamine/packages.config +++ b/src/UmbracoExamine/packages.config @@ -1,6 +1,6 @@  - +