Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 63 lines (41 sloc) 1.792 kB
09a1242 @micheljansen Initial commit to acts_as_full_text_searchable.
authored
1 = acts_as_full_text_searchable
2
b6fc80a @micheljansen initial commit
authored
3 Really simple extension to add full text search functionality to ActiveModel-style classes
09a1242 @micheljansen Initial commit to acts_as_full_text_searchable.
authored
4
07511a7 @micheljansen README
authored
5 Currently supports ActiveRecord and Mongoid.
6
7 == Usage
8 Load the library (add the gem to your Gemfile)
9 and add one line to the classes you would like to search like this:
10
11 class Person < ActiveRecord::Base
12 acts_as_full_text_searchable
13 end
14
15 class Page
16 include Mongoid::Document
17 acts_as_full_text_searchable
18 end
19
20 You can then query the classes like you would do with where():
eeb2bd1 @micheljansen updated README
authored
21 Person.full_text_search("Pete")
22
23 # equals
24 Person.where(:first_name => "Pete")
25 OR
26 Person.where(:last_name => "Pete")
27 OR
28 Person.where(:pet_name => "Pete")
07511a7 @micheljansen README
authored
29
30
31 AND is also supported:
eeb2bd1 @micheljansen updated README
authored
32 Person.full_text_search("Pete", :method => :and)
07511a7 @micheljansen README
authored
33
34
3fe1ac2 @micheljansen updated README with more examples
authored
35 You can use anything that goes normally goes into where() conditions, for example:
36 # on Mongoid:
37 Person.full_text_search(/any regex/)
38
39
07511a7 @micheljansen README
authored
40 Finally, there is also a global search, that operates on all classes that act as full_text_searchable:
41
eeb2bd1 @micheljansen updated README
authored
42 FullTextSearch.global_search("Pete")
07511a7 @micheljansen README
authored
43
44
45 == Limitations
46 * full_text_search only operates on the attributes defined on the class itself, not on any relations.
47 * global search only works on classes that have been loaded. If unsure, add them manually to FullTextSearch.classes
48
49
09a1242 @micheljansen Initial commit to acts_as_full_text_searchable.
authored
50 == Note on Patches/Pull Requests
51
52 * Fork the project.
53 * Make your feature addition or bug fix.
54 * Add tests for it. This is important so I don't break it in a
55 future version unintentionally.
56 * Commit, do not mess with rakefile, version, or history.
57 (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
58 * Send me a pull request. Bonus points for topic branches.
59
60 == Copyright
61
b6fc80a @micheljansen initial commit
authored
62 Copyright (c) 2010 Michel Jansen. See LICENSE for details.
Something went wrong with that request. Please try again.