Easy Search Core
The core package allows you to search indexes with configured engines through the Javascript API. The easy:search
package wraps this package together with easysearch:components
for convenience.
1import { Index, MongoDBEngine } from 'meteor/easysearch:core' 2 3// On Client and Server 4const Players = new Mongo.Collection('players') 5const PlayersIndex = new Index({ 6 collection: Players, 7 fields: ['name'], 8 engine: new MongoDBEngine(), 9}) 10 11Tracker.autorun(() => { 12 const cursor = PlayersIndex.search('Peter') 13 14 console.log(cursor.fetch()) // logs the documents 15 console.log(cursor.count()) // logs the count of all matched documents 16})
How to install
cd /path/to/project meteor add easysearch:core
NB: This package will use the erasaur:meteor-lodash
package if it is already installed in your application, else it will fallback to the standard Meteor underscore
package.