testing: mongo meilisearch

This commit is contained in:
Danny Avila 2023-03-16 16:22:08 -04:00
parent c27554ed2e
commit dcc13daf67
9 changed files with 654 additions and 3 deletions

24
api/app/search.js Normal file
View file

@ -0,0 +1,24 @@
const mongoose = require('mongoose');
const mongomeili = require('mongomeili');
const { messageSchema, Message } = require('../models/Message');
// Add the '{ meiliIndex: true }' property to index these attributes with MeiliSearch
// const MovieSchema = new mongoose.Schema({
// title: { type: String, required: true, meiliIndex: true },
// director: { type: String, required: true, meiliIndex: true },
// year: { type: String, required: true, meiliIndex: true }
// });
// Specify your MeiliSearch credentials
// messageSchema.plugin(mongomeili, {
// host: 'http://localhost:7700',
// apiKey: 'MASTER_KEY',
// indexName: 'messages' // Will get created automatically if it doesn't exist already
// });
(async () => {
await Message.syncWithMeili();
const result = await Message.meiliSearch({ query: 'quantum' });
console.log(result);
})();