-
Notifications
You must be signed in to change notification settings - Fork 343
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
Algolia addObjects called with empty model data calls api #304
Comments
Hmm that's a good question, I would have said that it should be fixed in Scout but now that I think about it, maybe it makes sense to fix in the client so more people avoid making empty calls 🤔 |
Is it though? Doesn't the |
Going to close this. Please provide a code example on how to reproduce this and I'll take another look. |
TL;DR: If a models toSearchableArray() returns an empty array the current behaviour in the AlgoliaEngine basically ends up calling the equivalent to PR #318 I have a use case where 4,000 models get updated from an external feed several times per hour. I can't call public function toSearchableArray()
{
if (!$this->isDirty('name')) {
return []; // I don't want to reindex this model but I don't want to remove it
}
return [
'name' => $this->name
];
} The issue is that the update method of the engine will call scout/src/Engines/AlgoliaEngine.php Lines 37 to 60 in fa82a4d
I think either it should check if the Based on these lines, I think it's supposed to handle empty data itself? scout/src/Engines/AlgoliaEngine.php Lines 54 to 56 in fa82a4d
|
If line 55 is executed we end up calling
$index->addObjects([])
which makes a request to Algolia.scout/src/Engines/AlgoliaEngine.php
Lines 49 to 59 in d5b6913
I'm not sure whether this behaviour should be improved in Scout or algolia/algoliasearch-client-php?
The text was updated successfully, but these errors were encountered: