Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

exposing update_ngram_index and remove_from_ngram_index for fast bulk…

…-updating the index. bumping version to 0.3.2
  • Loading branch information...
commit 12d2cee78b1a15e386e96d61d889b2ad39fffb36 1 parent ce17d2e
@aaw aaw authored
View
14 README.md
@@ -191,6 +191,20 @@ the AND of all of the individual results for each of the fields. Finally, if a f
but criteria for that filter aren't passed to `fulltext_search`, the result is as if the filter
had never been defined - you see both models that both pass and fail the filter in the results.
+Building the index
+------------------
+
+The fulltext index is build and maintained incrementally by hooking into `before_save` and
+`before_destroy` callbacks on each model that's being indexed. If you want to build an index
+on existing models, you can call the `update_ngram_index` method on each instance:
+
+ Artwork.all.each { |artwork| artwork.update_ngram_index }
+
+You can also remove instances in bulk from the index with the `remove_from_ngram_index`
+method:
+
+ Artwork.all.each { |artwork| artwork.remove_from_ngram_index }
+
Running the specs
-----------------
View
2  VERSION
@@ -1 +1 @@
-0.3.1
+0.3.2
View
2  lib/mongoid_fulltext.rb
@@ -109,8 +109,6 @@ def all_ngrams(str, config, bound_number_returned=true)
end
- protected
-
def update_ngram_index
self.mongoid_fulltext_config.each_pair do |index_name, fulltext_config|
# remove existing ngrams from external index
View
4 mongoid_fulltext.gemspec
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{mongoid_fulltext}
- s.version = "0.3.1"
+ s.version = "0.3.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Aaron Windsor"]
- s.date = %q{2011-04-14}
+ s.date = %q{2011-04-19}
s.description = %q{Full-text search for the Mongoid ORM, using n-grams extracted from text}
s.email = %q{aaron.windsor@gmail.com}
s.extra_rdoc_files = [
Please sign in to comment.
Something went wrong with that request. Please try again.