Skip to content

Fix entity mapping not working correctly #33

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

Merged

Conversation

kermitsxb
Copy link
Contributor

Small fix for the bundle to work correctly with last version of meilisearch

@emulienfou
Copy link
Contributor

Thanks @kermitsxb for the PR.
Can you write some tests please?

@kermitsxb
Copy link
Contributor Author

@emulienfou I have written a small test that assert that the searchService returns something. I took the index data part from the CommandsTest

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 a lot for this PR @kermitsxb!! And thanks for the test addition!

One question to be sure that I understand: does this error appear only when the hits array was empty?

@@ -215,6 +215,11 @@ public function search(
$ids = $this->engine->search($query, $this->searchableAs($className), $requestOptions);
$results = [];

// Check if the engine return results in "hits" key
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
// Check if the engine return results in "hits" key
// Check if the engine returns results in "hits" key

@kermitsxb
Copy link
Contributor Author

You're welcome @curquiza, thank you all to provide this amazing bundle.

It looks like the meilisearch-http returns an array with the results of the search having an "hits" key (cf : https://github.com/meilisearch/MeiliSearch/blob/dec0e2545d5878a4b316f3f5549373f091dc8328/meilisearch-http/src/helpers/meilisearch.rs on line 239, the array is built before). This has been added 14 months ago.

The Symfony function I've worked on didn't iterate on that array result but on the returned parent array. In order to keep the function working with people using older version I just set the array we iterate on later with the correct array if the key "hits" exists.

@curquiza curquiza linked an issue Dec 16, 2020 that may be closed by this pull request
@curquiza
Copy link
Member

In order to keep the function working with people using older version I just set the array we iterate on later with the correct array if the key "hits" exists.

Until MeiliSearch is stable, we don't want to add maintenance for the old version of MeiliSearch in the integration tools code bases. Plus, 14 months ago is a really long time for MeiliSearch, there were no integration plugins and this one didn't even exist.

So, I don't really know where the bug comes from because I really doubt the users in the issue use one of the oldest versions of MeiliSearch -> they would have a LOT of other problems.
Do you know where the bug comes from and why the addition you've made would fix it? 🙂

@kermitsxb
Copy link
Contributor Author

I don't know where the bug comes from since I've started using the bundle and it wouldn't work properly. The only thing I know is that the result are not passed the good way into the function and the fix I've made make it work.

@emulienfou
Copy link
Contributor

Hi @kermitsxb it's probably a mistake from me and forgot to add unit testing for this part of code and tested it correctly.

So instead of doing:

 if (isset($ids['hits'])) {
            $ids = $ids['hits'];
        }

Can you directly update the foreach loop:

foreach ($ids as $objectID)

And I think we will need to check before entering in the foreach loop if $ids['hits'] exists otherwise throwing an issue.

@kermitsxb
Copy link
Contributor Author

@emulienfou that's strange that the issue was not encounter before 🤔

I'll correct that tomorrow

@curquiza
Copy link
Member

Thanks to both of you guys for your involvement!

@curquiza
Copy link
Member

curquiza commented Jan 5, 2021

Hello @kermitsxb! Do you have some issue with this PR? Is there something we can do for helping?

@kermitsxb
Copy link
Contributor Author

Hello @curquiza ! Excuse me for the delay, I was on holiday and just came back to work yesterday, I'm gonna fixed this issue this week and update the PR ;)

@curquiza
Copy link
Member

curquiza commented Jan 5, 2021

Take your time @kermitsxb! It was just to be informed about the status of this PR 🙂
Thanks for your involvement and your quick answer!

@kermitsxb
Copy link
Contributor Author

Hi @curquiza @emulienfou,

I've updated the PR with your recommendations.

curquiza
curquiza previously approved these changes Jan 13, 2021
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.

I would rather the typo I have already noticed (https://github.com/meilisearch/meilisearch-symfony/pull/33/files#r542596071) before merging, otherwise, it seems ok 🙂
Is it ok for your @emulienfou?

@curquiza curquiza requested a review from emulienfou January 13, 2021 13:49
@curquiza curquiza changed the title Fix/#23 entity mapping not working correctly Fix entity mapping not working correctly Jan 21, 2021
@curquiza
Copy link
Member

Let's merge it because we don't have any feedback of emulienfou who might be busy 🙂

@emulienfou, you still can require changes of course if you see something wrong.

bors merge

@bors bors bot merged commit 6028001 into meilisearch:master Jan 21, 2021
@bors
Copy link
Contributor

bors bot commented Jan 21, 2021

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.

Entity mapping not working correctly?
3 participants