Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
danFbach committed Nov 11, 2024
1 parent 7010b39 commit ed6924f
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ JSON Output:
All the supported options are described in the [search parameters](https://www.meilisearch.com/docs/reference/api/search#search-parameters) section of the documentation.

```c#
SearchResult<Movie> movies = await index.SearchAsync<Movie>(
var movies = await index.SearchAsync<Movie>(
"car",
new SearchQuery
{
Expand Down Expand Up @@ -211,7 +211,7 @@ Note that MeiliSearch will rebuild your index whenever you update `FilterableAtt
Then, you can perform the search:

```c#
SearchResult<Movie> movies = await index.SearchAsync<Movie>(
var movies = await index.SearchAsync<Movie>(
"wonder",
new SearchQuery
{
Expand Down Expand Up @@ -239,6 +239,41 @@ JSON Output:
}
```

#### Search with Limit and Offset

You can paginate search results by making queries combining both [offset](https://www.meilisearch.com/docs/reference/api/search#offset) and [limit](https://www.meilisearch.com/docs/reference/api/search#limit).

```c#
var results = await index.SearchAsync<T>(query, new SearchQuery()
{
Limit = 5,
Offset = 0
});

if (results is SearchResult<T> limitedResults)
{
var estimatedTotalHits = limitedResults.EstimatedTotalHits;
}
```

#### Search with defined Number of results per page

To get paginated results with page numbers, the [HitsPerPage](https://www.meilisearch.com/docs/reference/api/search#number-of-results-per-page) and [Page](https://www.meilisearch.com/docs/reference/api/search#page) properties must be defined.

```c#
var results = await index.SearchAsync<T>(query, new SearchQuery()
{
HitsPerPage = pageSize,
Page = pageNumber,
});

if (results is PaginatedSearchResult<T> paginatedResults)
{
var totalHits = paginatedResults.TotalHits;
var totalPages = paginatedResults.TotalPages;
}
```

## 🤖 Compatibility with Meilisearch

This package guarantees compatibility with [version v1.x of Meilisearch](https://github.com/meilisearch/meilisearch/releases/latest), but some features may not be present. Please check the [issues](https://github.com/meilisearch/meilisearch-dotnet/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+label%3Aenhancement) for more info.
Expand Down

0 comments on commit ed6924f

Please sign in to comment.