From 1c4cab521d15583749bbbd4505ccf05937f664ab Mon Sep 17 00:00:00 2001 From: Matthew Care Date: Wed, 3 Nov 2021 08:32:48 +0100 Subject: [PATCH] Published Content Query has "skip" applied twice (#11378) * Fix double skip Skipping is done as part of the query now, causing `skip` to be applied twice * More instances of skipping Fix more areas where skip is applied twice --- src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs | 4 +--- .../Examine/ExamineUmbracoIndexingHandler.cs | 5 ++--- src/Umbraco.Infrastructure/PublishedContentQuery.cs | 4 ++-- .../Controllers/ExamineManagementController.cs | 4 +--- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs b/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs index a77bee7c4426..b8a942edc58e 100644 --- a/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs +++ b/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs @@ -145,9 +145,7 @@ public IEnumerable Search(string query, UmbracoEntityTypes entity totalFound = result.TotalItemCount; - var pagedResult = result.Skip(Convert.ToInt32(pageIndex)); - - return pagedResult; + return result; } private bool BuildQuery(StringBuilder sb, string query, string searchFrom, List fields, string type) diff --git a/src/Umbraco.Infrastructure/Examine/ExamineUmbracoIndexingHandler.cs b/src/Umbraco.Infrastructure/Examine/ExamineUmbracoIndexingHandler.cs index 4fbbb35a6d82..0d881888a14d 100644 --- a/src/Umbraco.Infrastructure/Examine/ExamineUmbracoIndexingHandler.cs +++ b/src/Umbraco.Infrastructure/Examine/ExamineUmbracoIndexingHandler.cs @@ -194,9 +194,8 @@ public void DeleteDocumentsForContentTypes(IReadOnlyCollection removedConte .Field("nodeType", id.ToInvariantString()) .Execute(QueryOptions.SkipTake(page * pageSize, pageSize)); total = results.TotalItemCount; - var paged = results.Skip(page * pageSize); - - foreach (ISearchResult item in paged) + + foreach (ISearchResult item in results) { if (int.TryParse(item.Id, NumberStyles.Integer, CultureInfo.InvariantCulture, out int contentId)) { diff --git a/src/Umbraco.Infrastructure/PublishedContentQuery.cs b/src/Umbraco.Infrastructure/PublishedContentQuery.cs index e149e092d849..d8119f919c71 100644 --- a/src/Umbraco.Infrastructure/PublishedContentQuery.cs +++ b/src/Umbraco.Infrastructure/PublishedContentQuery.cs @@ -295,7 +295,7 @@ public IEnumerable Search(string term, int skip, int take totalRecords = results.TotalItemCount; return new CultureContextualSearchResults( - results.Skip(skip).ToPublishedSearchResults(_publishedSnapshot.Content), _variationContextAccessor, + results.ToPublishedSearchResults(_publishedSnapshot.Content), _variationContextAccessor, culture); } @@ -324,7 +324,7 @@ public IEnumerable Search(IQueryExecutor query, int skip, totalRecords = results.TotalItemCount; - return results.Skip(skip).ToPublishedSearchResults(_publishedSnapshot); + return results.ToPublishedSearchResults(_publishedSnapshot); } /// diff --git a/src/Umbraco.Web.BackOffice/Controllers/ExamineManagementController.cs b/src/Umbraco.Web.BackOffice/Controllers/ExamineManagementController.cs index de3125ad6416..008582b6b3b8 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/ExamineManagementController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ExamineManagementController.cs @@ -91,12 +91,10 @@ public ActionResult GetSearchResults(string searcherName, string return SearchResults.Empty(); } - var pagedResults = results.Skip(pageIndex * pageSize); - return new SearchResults { TotalRecords = results.TotalItemCount, - Results = pagedResults.Select(x => new SearchResult + Results = results.Select(x => new SearchResult { Id = x.Id, Score = x.Score,