Skip to content

Commit

Permalink
Release 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
callumbwhyte committed Jun 22, 2023
1 parent 1585f06 commit 9c8e981
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/) and this project adheres to [Semantic Versioning](https://semver.org/).

## [3.1.0] - 2023-06-22
### Added
* Easier paging of `ISearchResults` with new `Page` extensions

### Changed
* `SearchHelper` is now obsolete and will be removed in a future version, use extensions instead

## [3.0.2] - 2023-02-08
### Added
* Overload for the `Page` method within `SearchHelper` that returns a page count
Expand Down Expand Up @@ -91,7 +98,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/) and this
### Added
* Initial release of Search Extensions for Umbraco 8.1

[Unreleased]: https://github.com/callumbwhyte/umbraco-search-extensions/compare/release-3.0.2...HEAD
[Unreleased]: https://github.com/callumbwhyte/umbraco-search-extensions/compare/release-3.1.0...HEAD
[3.1.0]: https://github.com/callumbwhyte/umbraco-search-extensions/compare/release-3.0.2...release-3.1.0
[3.0.2]: https://github.com/callumbwhyte/umbraco-search-extensions/compare/release-3.0.1...release-3.0.2
[3.0.1]: https://github.com/callumbwhyte/umbraco-search-extensions/compare/release-3.0.0...release-3.0.1
[3.0.0]: https://github.com/callumbwhyte/umbraco-search-extensions/compare/release-2.0.0...release-3.0.0
Expand Down
20 changes: 7 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,25 @@ query.And().GroupedOr(string[] fields, string culture)

### Searching

The `SearchHelper` class contains logic for commonly performed actions when searching, particularly helpful for creating paged search functionality.

The `Get<T>` method gets all results for a query cast to a given type, including `IPublishedContent`.
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`.

```
var query = searcher.CreatePublishedQuery();
var results = searchHelper.Get<T>(query, out int totalResults);
var searchResults = query.Execute();
var results = searchResults.Page<T>(query, int page, int perPage, out int totalPages, out int totalResults);
```

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`.
The total number of pages and results are exposed as an `out` parameter, but can be disgarded if not needed like so:

```
var query = searcher.CreatePublishedQuery();
var results = searchHelper.Page<T>(query, int page, int perPage, out int totalResults);
searchResults.Page<T>(query, int page, int perPage, out _, out _);
```

All helper methods provide the total number of results found as an `out` parameter.

### Results

For more specific cases where the `SearchHelper` is not appropriate, the same features for accessing strongly typed results are available as extension methods.

An entire results collection can be cast to a type like this:
An entire results collection can be cast to a list of a given type like this:

```
var results = query.Execute().GetResults<T>();
Expand Down

0 comments on commit 9c8e981

Please sign in to comment.