You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `SearchHelper` class contains logic for commonly performed actions when searching, particularly helpful for creating paged search functionality.
74
-
75
-
The `Get<T>` method gets all results for a query cast to a given type, including `IPublishedContent`.
73
+
The `Page<T>` extension methods efficiently get a given number of items *(`perPage`)* at a specific position *(`page`)* from Examine's `ISearchResults`. An optional type constraint can be added to also return paged results cast to `IPublishedContent`.
76
74
77
75
```
78
76
var query = searcher.CreatePublishedQuery();
79
77
80
-
var results = searchHelper.Get<T>(query, out int totalResults);
78
+
var searchResults = query.Execute();
79
+
80
+
var results = searchResults.Page<T>(query, int page, int perPage, out int totalPages, out int totalResults);
81
81
```
82
82
83
-
The `Page<T>` method efficiently gets a given number of items *(`perPage`)* at a specific position *(`page`)* in the results for a query. An optional type constraint can be added to also return paged results cast to `IPublishedContent`.
83
+
The total number of pages and results are exposed as an `out` parameter, but can be disgarded if not needed like so:
84
84
85
85
```
86
-
var query = searcher.CreatePublishedQuery();
87
-
88
-
var results = searchHelper.Page<T>(query, int page, int perPage, out int totalResults);
86
+
searchResults.Page<T>(query, int page, int perPage, out _, out _);
89
87
```
90
88
91
-
All helper methods provide the total number of results found as an `out` parameter.
92
-
93
89
### Results
94
90
95
-
For more specific cases where the `SearchHelper` is not appropriate, the same features for accessing strongly typed results are available as extension methods.
96
-
97
-
An entire results collection can be cast to a type like this:
91
+
An entire results collection can be cast to a list of a given type like this:
0 commit comments