diff --git a/src/Umbraco.Web/IPublishedContentQuery.cs b/src/Umbraco.Web/IPublishedContentQuery.cs index 72ca5d6ddb..c3a065b9dc 100644 --- a/src/Umbraco.Web/IPublishedContentQuery.cs +++ b/src/Umbraco.Web/IPublishedContentQuery.cs @@ -35,11 +35,26 @@ namespace Umbraco.Web /// /// Searches content. /// + /// Term to search. + /// Optional culture. + /// Optional index name. + /// + /// When the is not specified, all cultures are searched. + /// IEnumerable Search(string term, string culture = null, string indexName = null); /// /// Searches content. /// + /// Term to search. + /// Numbers of items to skip. + /// Numbers of items to return. + /// Total number of matching items. + /// Optional culture. + /// Optional index name. + /// + /// When the is not specified, all cultures are searched. + /// IEnumerable Search(string term, int skip, int take, out long totalRecords, string culture = null, string indexName = null); /// diff --git a/src/Umbraco.Web/PublishedContentQuery.cs b/src/Umbraco.Web/PublishedContentQuery.cs index 79f6e07282..3d8f36ec1a 100644 --- a/src/Umbraco.Web/PublishedContentQuery.cs +++ b/src/Umbraco.Web/PublishedContentQuery.cs @@ -198,12 +198,13 @@ namespace Umbraco.Web var searcher = umbIndex.GetSearcher(); + // default to max 500 results + var count = skip == 0 && take == 0 ? 500 : skip + take; + ISearchResults results; if (culture.IsNullOrWhiteSpace()) { - results = searcher.Search(term, (skip == 0 && take == 0 - ? 500 //default max results - : skip + take)); + results = searcher.Search(term, count); } else { @@ -219,10 +220,8 @@ namespace Umbraco.Web cultureFields.Add(field); } - results = qry.And().ManagedQuery(term, cultureFields.ToArray()).Execute((skip == 0 && take == 0 - ? 500 //default max results - : skip + take)); - + qry = qry.And().ManagedQuery(term, cultureFields.ToArray()); + results = qry.Execute(count); } totalRecords = results.TotalItemCount;