Module: Lunar
- Extended by:
- Connection
- Defined in:
- lib/lunar.rb,
lib/lunar/index.rb,
lib/lunar/words.rb,
lib/lunar/scoring.rb,
lib/lunar/stopwords.rb,
lib/lunar/connection.rb,
lib/lunar/fuzzy_word.rb,
lib/lunar/result_set.rb,
lib/lunar/fuzzy_matches.rb,
lib/lunar/range_matches.rb,
lib/lunar/number_matches.rb,
lib/lunar/keyword_matches.rb
Defined Under Namespace
Modules: Connection, Stopwords Classes: FuzzyMatches, FuzzyWord, Index, KeywordMatches, NumberMatches, RangeMatches, ResultSet, Scoring, Words
Constant Summary collapse
- VERSION =
'0.6.0'
Class Method Summary collapse
-
.delete(namespace, id) ⇒ nil
Delete a document identified by its namespace and id.
- .encode(word) ⇒ Object
-
.index(namespace) {|Lunar::Index| ... } ⇒ Lunar::Index
Index any document using a namespace.
- .metaphone(word) ⇒ Object
- .nest ⇒ Object
-
.search(namespace, options, finder = lambda { |id| namespace[id] }) ⇒ Object
Search for a document, scoped under a namespace.
Methods included from Connection
Class Method Details
.delete(namespace, id) ⇒ nil
Delete a document identified by its namespace and id.
51 52 53 |
# File 'lib/lunar.rb', line 51 def self.delete(namespace, id) Index.new(namespace).delete(id) end |
.encode(word) ⇒ Object
97 98 99 |
# File 'lib/lunar.rb', line 97 def self.encode(word) Base64.encode64(word).gsub("\n", "") end |
.index(namespace) {|Lunar::Index| ... } ⇒ Lunar::Index
Index any document using a namespace. The namespace can be a class, or a plain Symbol/String.
42 43 44 |
# File 'lib/lunar.rb', line 42 def self.index(namespace) Index.new(namespace).tap { |i| yield i } end |
.metaphone(word) ⇒ Object
92 93 94 |
# File 'lib/lunar.rb', line 92 def self.(word) Text::Metaphone.(word) end |
.nest ⇒ Object
102 103 104 |
# File 'lib/lunar.rb', line 102 def self.nest Nest.new(:Lunar, redis) end |
.search(namespace, options, finder = lambda { |id| namespace[id] }) ⇒ Object
Search for a document, scoped under a namespace.
84 85 86 87 88 89 |
# File 'lib/lunar.rb', line 84 def self.search(namespace, , finder = lambda { |id| namespace[id] }) sets = find_and_combine_sorted_sets_for(namespace, ) key = try_intersection_of_sorted_sets(namespace, sets, ) ResultSet.new(key, nest[namespace], finder) end |