fulltongo - simple keyword text search plugin for mongoose
Provides metaphone keyword indexing and search for a schema for Mongoose documents. Strongly based on mongoose-fts and reds
Options:
-
fields
: an array of paths you want watched and converted into keywords
Example:
var schema = new Schema({
name: { first: String, last: String, email: String },
tags: [String]
});
var opts = {};
opts.fields = ['name.first', 'name.last', 'name.email', 'tags'];
schema.plugin(app, opts);
var Person = mongoose.model('Person', schema);
This will introduce a few things to the schemea.
- Every new save, will reindex the fields provided when this was created under the
_keywords
path. - A static
search
method is added that takes aquery
parameter and acallback
- An indexAll method is added (this needs more testing) to index all existing documents in a collection
- An updateIndex that can be used to update the
_keywords
path as needed.
Notes
For now have a look at the tests to see how this works.
Mongoose Version
>= 2.x