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

fix for #577 #578

Closed
wants to merge 1 commit into from
Closed

fix for #577 #578

wants to merge 1 commit into from

Conversation

danFbach
Copy link
Contributor

Pull Request

Related issue

Fixes #577

What does this PR do?

  • brings the Offset, Limit and EstimatedTotalHits fields to ISearchable<T>
  • migrated fields in SearchResult<T> now use /// <inheritdoc/> as docs were also moved to ISearchable<T>

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Not sure if Offset and Limit also need to ported up, but i could envision a scenario where it would be useful, so I brought them along too.

Copy link

@migueltarga migueltarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@danFbach
Copy link
Contributor Author

I think I would retract this PR. There should probably be separate interfaces for offset and paginated results. This would better conform with API result object, which is polymorphic based on the request. Is this more what you all would be looking for?

@danFbach danFbach marked this pull request as draft November 11, 2024 19:59
@migueltarga
Copy link

The way you have it looks completely fine to me:
https://www.meilisearch.com/docs/reference/api/search#response

@danFbach
Copy link
Contributor Author

@migueltarga The problem is that they already have both SearchResult<T> and PaginatedSearchResult<T> as implementations of ISearchable<T> This should enable you to do something like this...

For paginated results.

var results = await index.SearchAsync<MeilisearchResultProductModel>(query, new SearchQuery()
{
    ShowRankingScore = true,
    Page = page,
    HitsPerPage = pageSize,
    Filter = buildFilter(categoryIds, manufacturerId, currentStoreId),
});

if (results is PaginatedSearchResult<MeilisearchResultProductModel> paginatedResult)
{
    var totalPages = paginatedResult.TotalPages
}

Or for offset style request:

if (results is SearchResult<MeilisearchResultProductModel> searchResult)
{
    var totalHits = searchResult.EstimatedTotalHits;
}

Will be testing this shortly and will report if it works as expected.

@danFbach
Copy link
Contributor Author

danFbach commented Nov 11, 2024

@migueltarga I can confirm that the following syntax is valid.

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

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

Docs should probably be updated to make this more obvious.

@migueltarga
Copy link

@danFbach Thank you for the explanation and the example!

danFbach added a commit to danFbach/meilisearch-dotnet that referenced this pull request Nov 11, 2024
@danFbach danFbach closed this Nov 11, 2024
@danFbach danFbach mentioned this pull request Nov 11, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EstimatedTotalHits Removed
2 participants