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