Meteor & Svelte Search over Collections

i want to simply implement a search bar into my Meteor project , i have found some Plugins but sadly it only depends on React and Blaze .

so my question is : how to make a fast reactive searchbar engine for my collection using svelte (only one)

No need to worry about react and blaze - Search is agnostic of frontend framework, because you just parse json into a div from the return of a function.

All JS and npm node packages will work in Meteor, straight out the box, the only caveat / complication to it is that there is a split of server/client code, so you need to send the return from the server to the client via a Meteor Method that is called async from the client and the output fed into your display. Most people like to use a templating layer to wrap that in, although it is just HTML, JS and some JSON or plain text response. You can use Svelte or any language you want for the response because you just load a url like /mySearchServer?query=what+I+am+searching+for and parse the response it spits out with JS or jQuery / whatever you like. It’s the same design pattern for any language because of how tcp/ip, web browsers and http works.

I would use a Meteor method too. Actually, I use it.

An input with a on:change ="{searchHandler} instead of on:change you can explore on:keydown

The search handler performs a to the server to search the collection.Since I’m not publishing/subscribing to the whole collection.

But this won’t work if you don’t create a text index in your collection. Check the Mongo documentation for it.

1 Like

never heard about mongodb text indexes , i will try to implement that , thanks.