shanna-dm-sphinx-adapter 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Rakefile +1 -1
- data/dm-sphinx-adapter.gemspec +1 -1
- data/lib/dm-sphinx-adapter/adapter.rb +9 -7
- metadata +1 -1
data/History.txt
CHANGED
data/Rakefile
CHANGED
data/dm-sphinx-adapter.gemspec
CHANGED
@@ -37,10 +37,7 @@ module DataMapper
|
|
37
37
|
# DataMapper uri or options hash.
|
38
38
|
def initialize(name, uri_or_options)
|
39
39
|
super # Set up defaults.
|
40
|
-
|
41
|
-
options = normalize_options(uri_or_options)
|
42
|
-
@client = Riddle::Client.new(options.delete(:host), options.delete(:port))
|
43
|
-
options.each{|k, v| @client.method("#{k}=".to_sym).call(v) if @client.respond_to?("#{k}=".to_sym)}
|
40
|
+
@options = normalize_options(uri_or_options)
|
44
41
|
end
|
45
42
|
|
46
43
|
def create(resources) #:nodoc:
|
@@ -118,10 +115,15 @@ module DataMapper
|
|
118
115
|
# Array<Hash>:: An array of document hashes. <tt>[{:id => 1, ...}, {:id => 2, ...}]</tt>
|
119
116
|
# Array<>:: An empty array if no documents match.
|
120
117
|
def read(query)
|
121
|
-
from
|
122
|
-
search
|
118
|
+
from = indexes(query.model).map{|index| index.name}.join(', ')
|
119
|
+
search = Sphinx::Query.new(query).to_s
|
120
|
+
client = Riddle::Client.new(@options[:host], @options[:port])
|
121
|
+
|
122
|
+
# You can set some options that aren't set by the adapter.
|
123
|
+
@options.except(:host, :port, :match_mode, :limit, :offset, :sort_mode, :sort_by).each do |k, v|
|
124
|
+
client.method("#{k}=".to_sym).call(v) if client.respond_to?("#{k}=".to_sym)
|
125
|
+
end
|
123
126
|
|
124
|
-
client = @client.dup
|
125
127
|
client.match_mode = :extended
|
126
128
|
client.filters = search_filters(query) # By attribute.
|
127
129
|
client.limit = query.limit.to_i if query.limit
|