= Hunt
Insanely stupid and basic indexed search for MongoMapper. Probably pointless, but something I am playing around with on side projects.
== Usage
Declare the plugin.
class Note include MongoMapper::Document plugin Hunt
key :title, String
key :body, String
key :tags, Array
timestamps!
searches :title, :body, :tags
end
This creates a key named searches that is a Hash. Title, body, and tags get mashed together before save into a unique array of stemmed words and stored in searches.default.
You can index the terms individually or with any other combination of keys.
Note.ensure_index :'searches.default' # or ... Note.ensure_index [[:user_id, Mongo::Ascending], [:'searches.default', Mongo::Ascending]]
You also get a search class method that returns a scope.
Note.search('mongodb')
Note.search('mongodb').all
Note.search('mongodb').paginate(:page => 1)
Note.search('mongodb').count
Note.search('mongodb is awesome')
== Note on Patches/Pull Requests
== Copyright
Copyright (c) 2010 John Nunemaker. See LICENSE for details.