Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added docs on limiting results #299

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion docs/sorting.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,37 @@ var orderedDescendingResults = searcher

## Limiting results

_TODO: Fill this in..._
To limit results we can use the `QueryOptions` class when executing a search query. The `QueryOptions` class provides the ability to skip and take.

Examples:

```csharp
var searcher = indexer.GetSearcher();

var takeFirstTenInIndex = searcher
.CreateQuery()
.All()
.Execute(QueryOptions.SkipTake(0, 10))

var skipFiveAndTakeFirstTenInIndex = searcher
.CreateQuery()
.All()
.Execute(QueryOptions.SkipTake(5, 10))

var takeThreeResults = searcher
.CreateQuery("content")
.Field("writerName", "administrator")
.OrderBy(new SortableField("name", SortType.String))
.Execute(QueryOptions.SkipTake(0, 3));

var takeSevenHundredResults = searcher
.CreateQuery("content")
.Field("writerName", "administrator")
.OrderByDescending(new SortableField("name", SortType.String))
.Execute(QueryOptions.SkipTake(0, 700));
```

By default when using `Execute()` or `Execute(QueryOptions.SkipTake(0))` where no take parameter is provided the take of the search will be set to `QueryOptions.DefaultMaxResults` (500).

## Paging

Expand Down