I’m using meteorhacks:search-source
in combination with typeahead
to enable suggest search. Works pretty well. However, this package is one of Arunoda’s legacy and won’t be developed any further. So I am wondering if there’s an alternative that’s still actively maintained?
1 Like
Using it for exactly the same situation, and would be nice if someone could find a long-term support replacement. But anyway, we can always try to fix search-sources in a local package.
Truth be told, I do not think this should have ever been a package. All you need to do - and all it does - is query MongoDB with a regex query.
Here’s a snippet that can help you do the same. It even works on the client:
Meteor.publish("search", function (keyword) {
var search = keyword.replace(/[^\w\s]/g, "");
var textSearch = new RegExp(search, "i");
return Collection.find({
$or: {
fieldNameA: textSearch,
fieldNameB: textSearch
}
})
})
Can you comment this snippet a little? I don’t follow why you put the same value textSearch in fieldName A and B.