setup message population on search

This commit is contained in:
Daniel Avila 2023-03-18 18:40:53 -04:00
parent 4197a92609
commit 4e6168d8fa
5 changed files with 47 additions and 23 deletions

View file

@ -46,4 +46,13 @@ router.get('/clear', async function (req, res) {
res.send('cleared');
});
router.get('/test', async function (req, res) {
const { q } = req.query;
const messages = (await Message.meiliSearch(q, { attributesToHighlight: ['text'] }, true)).hits.map(message => {
const { _formatted, ...rest } = message;
return { ...rest, searchResult: true, text: _formatted.text };
});
res.send(messages);
});
module.exports = router;