-
Notifications
You must be signed in to change notification settings - Fork 47
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
Support Multi-Search #321
Support Multi-Search #321
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #321 +/- ##
==========================================
+ Coverage 89.47% 90.22% +0.75%
==========================================
Files 11 13 +2
Lines 684 757 +73
==========================================
+ Hits 612 683 +71
- Misses 72 74 +2 ☔ View full report in Codecov by Sentry. |
6222e8e
to
1eb2b84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be ready for review (but I don't think it should be merged in this state), please see the comments I left.
|
||
private | ||
|
||
def load_results(klass, result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need some guidance on how pagination would be expected to work in multi search.
Paginate the results of each search, paginate the search as a whole, or both? Waiting on a review before going through with a solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know and per the docs: https://www.meilisearch.com/docs/reference/api/multi_search
You handle the pagination by each "block" of returned data. Because essentially the multi_search is just a way of making multiple requests at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That checks out, since each search can have its own pagination options. This would mean that displaying all of the results together would not make much sense, since they would never be on the same "page".
Perhaps I should expect that #each_result
should be the main way to use a MultiSearchResult
? It might make most sense in the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I am quite unsure about how the users are going to make use of this feature, so I would prefer to have some external output before applying more changes to it. But I'm on your side to whichever option you may prefer.
module MeiliSearch | ||
module Rails | ||
class << self | ||
def multi_search(searches) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placed the multi search method as MeiliSearch::Rails.multi_search
for the time being, but it does not feel like we should expect our users to write it all out.
Maybe ApplicationRecord.multi_search
, or give all models the same, generic, multi_search
method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for convenience, we could add it to ApplicationRecord
indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a good starting point to have this feature on rails!
I made some comments, let me know if you agree with them
|
||
private | ||
|
||
def load_results(klass, result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know and per the docs: https://www.meilisearch.com/docs/reference/api/multi_search
You handle the pagination by each "block" of returned data. Because essentially the multi_search is just a way of making multiple requests at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@ellnix merge when you want 😊 |
I do not think this is ready yet, I have to implement Bruno's suggestions and also some things I left out myself, for instance it's still not tested for MongoDB and Sequel. |
I was confused by the |
cc9f4aa
to
b0248af
Compare
Hey @ellnix I thought we were ok with releasing like this, most of my suggestions are not logic-related but style ones. Plus about this comment:
I'm not even sure we still can say that we support MongoDB in the first place, there is no "real" test coverage for MongoDB. |
Yeah, I thought I could somehow test them but that was my bad. Anyway the other changes I wanted to be done are done, this is ready to merge if it looks good to you now that pagination is implemented. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be good now, with the pagination :)
I didn't try locally, but looking closely to the tests, they seem good enough!
LGTM
bors merge |
Build succeeded: |
Pull Request
Related issue
Fixes #254
I thought I'd make a draft PR to discuss and review API decisions. I discussed the method signature of a theoretical
multi_search
in #254 (comment), if there is no problem I will proceed with this one:Initially I expected that the return type would be a simple array, however this might not be ideal since it
I am thinking of either a simple hash or a hash-like class with convenience methods.