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

Indexes::search() improvements #120

Merged
merged 2 commits into from
Dec 21, 2020

Conversation

Guikingone
Copy link
Contributor

@Guikingone Guikingone commented Nov 24, 2020

Hi everyone 👋

As mentioned here: #119, here's the SearchResult class and the improvements that comes with it.

There's just a small "DX" way that I'm not sure about:

  • When using SearchResult::filter() should the hits array be reset to 0 or stay as it?

IMO, the array could stays as it as we return a new SearchResult object but sometimes, it could be good idea to reset the keys from 0 (loops, etc) 🤔

Thanks for the feedback and have a great day 🙂

@Guikingone Guikingone force-pushed the feat/search_result branch 2 times, most recently from 823beb5 to 4de3173 Compare November 24, 2020 17:53
@curquiza
Copy link
Member

Hello @Guikingone! So sorry for the delay!!!
The integration team is mostly ok with this change! 😄
I just need a final discussion with the developer relation manager before reviewing and merging this PR: indeed, we would apply this change in other SDKs (ruby, python...), that's why I want to be sure before taking this kind of decision that differs from Algolia!
Thanks again for your patience and your suggestion -> that's exactly the kind of solution I was looking for to help users managing their search results!

@curquiza curquiza linked an issue Dec 15, 2020 that may be closed by this pull request
@Guikingone Guikingone force-pushed the feat/search_result branch 5 times, most recently from 71be79a to 751e9b1 Compare December 16, 2020 07:42
@Guikingone
Copy link
Contributor Author

Hello @curquiza 👋

The checks are green after a small refactoring, feel free to review it when you have time, I've introduced the json() method as discussed 🙂

@curquiza
Copy link
Member

Thank you so much @Guikingone!
I review it asap! 👍

ppshobi
ppshobi previously approved these changes Dec 17, 2020
Copy link
Contributor

@ppshobi ppshobi left a comment

Choose a reason for hiding this comment

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

Seems good to me. Real nice touch with the tests

Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

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

Thanks for this huge job, I just ask for small modifications!

About your question, yes let it as it is for the moment, it seems ok for me 🙂

Again, thank you so much for your work 🙏 Be sure we are going to extend this way of handling search result to our other SDKs.

FYI: I'm not going to release right after merging this PR. I indeed need to discuss naming with my team, and most of all, another breaking PR is planned so I will do the push to Packagist after all the breaking changes are done 😇

src/Search/SearchResult.php Outdated Show resolved Hide resolved
src/Search/SearchResult.php Outdated Show resolved Hide resolved
Comment on lines 141 to 142
if (\array_key_exists('filteringHits', $options) && \is_callable($options['filteringHits'])) {
$searchResult = $searchResult->filter($options['filteringHits']);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (\array_key_exists('filteringHits', $options) && \is_callable($options['filteringHits'])) {
$searchResult = $searchResult->filter($options['filteringHits']);
if (\array_key_exists('transformHits', $options) && \is_callable($options['transformHits'])) {
$searchResult = $searchResult->filter($options['transformHits']);

Copy link
Member

Choose a reason for hiding this comment

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

I know this is "filtering" in PHP because we use the filter method. However, in the case of MeiliSearch, I'm afraid the users are confused with the filtering of MeiliSearch -> https://docs.meilisearch.com/guides/advanced_guides/filtering.html#filtering
That's why I suggest this name. Not sure this is the best, but we'll probably change it once all my team will come back from holidays and we can discuss the new naming 🙂 (I'm not going to push the package to Packagist before of course)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved 🙂

@Guikingone Guikingone added breaking-change The related changes are breaking for the users and removed breaking-change The related changes are breaking for the users labels Dec 21, 2020
Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

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

Finally merging! Thanks a lot @Guikingone and also @ppshobi! 🎉

bors merge

@bors
Copy link
Contributor

bors bot commented Dec 21, 2020

@bors bors bot merged commit 42adbd0 into meilisearch:master Dec 21, 2020
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.

Improve the search() method
3 participants