From ce568343ab613a8b7cf29e335aad71fc92e03fe4 Mon Sep 17 00:00:00 2001 From: Matthew Care Date: Thu, 23 Jun 2022 00:36:37 +0200 Subject: [PATCH] Issue 12551 search bug Previous optimisation incorrectly filtered the index fields needed to return published results --- src/Umbraco.Infrastructure/PublishedContentQuery.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Infrastructure/PublishedContentQuery.cs b/src/Umbraco.Infrastructure/PublishedContentQuery.cs index 891f938a2b..e8f25aeae1 100644 --- a/src/Umbraco.Infrastructure/PublishedContentQuery.cs +++ b/src/Umbraco.Infrastructure/PublishedContentQuery.cs @@ -24,6 +24,9 @@ public class PublishedContentQuery : IPublishedContentQuery private readonly IPublishedSnapshot _publishedSnapshot; private readonly IVariationContextAccessor _variationContextAccessor; + private static readonly HashSet s_returnedQueryFields = + new() { ExamineFieldNames.ItemIdFieldName, ExamineFieldNames.CategoryFieldName }; + /// /// Initializes a new instance of the class. /// @@ -293,8 +296,8 @@ public class PublishedContentQuery : IPublishedContentQuery ordering = query.ManagedQuery(term, fields); } - // Only select item ID field, because results are loaded from the published snapshot based on this single value - IOrdering? queryExecutor = ordering.SelectFields(_itemIdFieldNameHashSet); + // Filter selected fields because results are loaded from the published snapshot based on these + IOrdering? queryExecutor = ordering.SelectFields(s_returnedQueryFields); ISearchResults? results = skip == 0 && take == 0 @@ -328,8 +331,8 @@ public class PublishedContentQuery : IPublishedContentQuery if (query is IOrdering ordering) { - // Only select item ID field, because results are loaded from the published snapshot based on this single value - query = ordering.SelectFields(_itemIdFieldNameHashSet); + // Filter selected fields because results are loaded from the published snapshot based on these + query = ordering.SelectFields(s_returnedQueryFields); } ISearchResults? results = skip == 0 && take == 0