Hooks are not adding more than 100 documents on afterCreate
See original GitHub issueAs it appears when adding a huge dataset to MeiliSearch it stops at 100 entries. As this is not the expected behavior it is a bug.
queue.on('ready', function () {
queue.process(function (job, done) {
console.log('processing job ' + job.id);
console.log('job data page: ', job.data.page);
const mockCtx = {
params: { collection: job.data.collection },
send: (e) => e,
request: {},
};
fetchCollection(mockCtx, { page: job.data.page })
.then((r) => addCollectionRows(r))
.catch((e) => console.log('queue error', e));
console.log('processed job ' + job.data.page);
setTimeout(function () {
done(null, job.data.id);
}, 10);
});
console.log('listening for jobs and processing queued jobs...');
});
};
@MANTENN , lets continue here!
Could you try the following:
- Add your documents using the hooks
- Bug appears! there are only 100 entries.
- Using your meilisearch credentials try this route: https://docs.meilisearch.com/reference/api/updates.html#get-all-update-status
It should give back status on your document addition in MeiliSearch. Could you copy paste it here?
Also, is there a error thrown in the server logs?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Hooks
Hooks (also known as lifecycle events), are functions which are called before and after calls in sequelize are executed.
Read more >Understanding Vue.js Lifecycle Hooks
Lifecycle hooks allow you to know when your component is created, add… ... hook runs at the initialization of your component - data...
Read more >Mongoose v6.8.2: Middleware
Middleware (also called pre and post hooks) are functions which are passed control during execution of asynchronous functions. Middleware is specified on ...
Read more >Developing hooks - CloudFormation Command Line ...
Hooks proactively inspect the configuration of your AWS resources before provisioning. Hooks automatically inspect resources before they're provisioned.
Read more >Lifecycle Hooks
Each Vue component instance goes through a series of initialization steps when ... lifecycle hooks, giving users the opportunity to add their own...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Without the queue it’s still only with 100 records because the Strapi model fetches the first 100 documents.
My code creates pagination and loops through “pages” and queues them with bee-que(backed by redis). I created a video as well of me running the plugin from the master branch without any modifications–may be too long.
https://youtu.be/IyXbypNt7q8
I created a new branch as requested. Saved the files without a linter. I will just paste the code here considering my linter runs with git hooks will take more time again to make an another repo.
/config/functions/bootstrap.js
controllers/meilisearch.js
That’s for the queue
Hello! I see 😃 Thanks for the explaination. This is a good suggestion. Could you maybe make an issue on https://github.com/meilisearch/meilisearch ?
Ah yes, big datasets may suffer from all these fetches! Your suggestion addresses this problem. Until your suggestion is created, we could think about some configuration where you can add some Redis credentials and activate the queuing of the fetching like you did.
Meanwhile! There is another solution. Since the big problem is when you first add your whole collection to meiliSearch, it is also possible to add the collection in a separate script. Where you would add all your rows to meilisearch using
meilisearch-js
for example:Once this is done, if you used the same name as your collection in strapi (
big_dataset
in the code above), you do not need to add the collection as the checkbox will already be checked. Its not the perfect solution but we’ll get there 😃Meanwhile, it should at least work on smaller datasets! I will make the PR