dm-sphinx-adapter 0.6 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +13 -0
- data/Manifest.txt +2 -2
- data/README.txt +13 -0
- data/Rakefile +1 -1
- data/dm-sphinx-adapter.gemspec +6 -6
- data/lib/dm-sphinx-adapter.rb +1 -1
- data/lib/dm-sphinx-adapter/adapter.rb +19 -13
- data/lib/dm-sphinx-adapter/query.rb +4 -3
- data/test/files/model.rb +1 -0
- data/test/files/source.xml +39 -0
- data/test/files/sphinx.conf +36 -0
- data/test/helper.rb +11 -16
- data/test/test_adapter.rb +20 -36
- data/test/test_query.rb +1 -2
- metadata +5 -5
- data/test/files/mysql5.sphinx.conf +0 -97
- data/test/files/mysql5.sql +0 -26
data/History.txt
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
=== 0.7 / 2009-02-21
|
2
|
+
|
3
|
+
* Explicit repository names everywhere I can. DM ~> 0.9.10 and dm-sphinx-adapter 0.6.2 couldn't guess the default repository name.
|
4
|
+
|
5
|
+
=== 0.6.2 / 2008-12-16
|
6
|
+
|
7
|
+
* Fixed shallow .dup of riddle client errors. You need to upgrade if you are running 0.6.1.
|
8
|
+
|
9
|
+
=== 0.6.1 / 2008-12-16
|
10
|
+
|
11
|
+
* The adapter returns the entire Riddle::Client#query response so document :weight and :attributes are usable.
|
12
|
+
* Fixed broken naming convention bug. The AbstractAdapter constructor was not being called.
|
13
|
+
|
1
14
|
=== 0.6 / 2008-12-13
|
2
15
|
|
3
16
|
* Removed managed client and all related libs.
|
data/Manifest.txt
CHANGED
@@ -16,8 +16,8 @@ lib/riddle/client/filter.rb
|
|
16
16
|
lib/riddle/client/message.rb
|
17
17
|
lib/riddle/client/response.rb
|
18
18
|
test/files/model.rb
|
19
|
-
test/files/
|
20
|
-
test/files/
|
19
|
+
test/files/source.xml
|
20
|
+
test/files/sphinx.conf
|
21
21
|
test/helper.rb
|
22
22
|
test/test_adapter.rb
|
23
23
|
test/test_attribute.rb
|
data/README.txt
CHANGED
@@ -10,11 +10,24 @@ A DataMapper Sphinx adapter.
|
|
10
10
|
|
11
11
|
== Dependencies
|
12
12
|
|
13
|
+
Ruby::
|
13
14
|
* dm-core ~> 0.9.7
|
14
15
|
* dm-is-searchable ~> 0.9.7 (optional)
|
15
16
|
|
16
17
|
I'd recommend using the dm-more plugin dm-is-searchable instead of fetching the document id's yourself.
|
17
18
|
|
19
|
+
Sphinx::
|
20
|
+
* 0.9.8-r871
|
21
|
+
* 0.9.8-r909
|
22
|
+
* 0.9.8-r985
|
23
|
+
* 0.9.8-r1065
|
24
|
+
* 0.9.8-r1112
|
25
|
+
* 0.9.8-rc1 (gem version: 0.9.8.1198)
|
26
|
+
* 0.9.8-rc2 (gem version: 0.9.8.1231)
|
27
|
+
* 0.9.8 (gem version: 0.9.8.1371)
|
28
|
+
|
29
|
+
Internally the Riddle client library is used.
|
30
|
+
|
18
31
|
== Install
|
19
32
|
|
20
33
|
* Via git: git clone git://github.com/shanna/dm-sphinx-adapter.git
|
data/Rakefile
CHANGED
data/dm-sphinx-adapter.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{dm-sphinx-adapter}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.7"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Shane Hanna"]
|
9
|
-
s.date = %q{
|
9
|
+
s.date = %q{2009-02-21}
|
10
10
|
s.description = %q{A DataMapper Sphinx adapter.}
|
11
11
|
s.email = ["shane.hanna@gmail.com"]
|
12
12
|
s.extra_rdoc_files = ["History.txt", "LICENCE.txt", "Manifest.txt", "README.txt"]
|
13
|
-
s.files = ["History.txt", "LICENCE.txt", "Manifest.txt", "README.txt", "Rakefile", "dm-sphinx-adapter.gemspec", "lib/dm-sphinx-adapter.rb", "lib/dm-sphinx-adapter/adapter.rb", "lib/dm-sphinx-adapter/attribute.rb", "lib/dm-sphinx-adapter/index.rb", "lib/dm-sphinx-adapter/query.rb", "lib/dm-sphinx-adapter/resource.rb", "lib/riddle.rb", "lib/riddle/client.rb", "lib/riddle/client/filter.rb", "lib/riddle/client/message.rb", "lib/riddle/client/response.rb", "test/files/model.rb", "test/files/
|
13
|
+
s.files = ["History.txt", "LICENCE.txt", "Manifest.txt", "README.txt", "Rakefile", "dm-sphinx-adapter.gemspec", "lib/dm-sphinx-adapter.rb", "lib/dm-sphinx-adapter/adapter.rb", "lib/dm-sphinx-adapter/attribute.rb", "lib/dm-sphinx-adapter/index.rb", "lib/dm-sphinx-adapter/query.rb", "lib/dm-sphinx-adapter/resource.rb", "lib/riddle.rb", "lib/riddle/client.rb", "lib/riddle/client/filter.rb", "lib/riddle/client/message.rb", "lib/riddle/client/response.rb", "test/files/model.rb", "test/files/source.xml", "test/files/sphinx.conf", "test/helper.rb", "test/test_adapter.rb", "test/test_attribute.rb", "test/test_index.rb", "test/test_query.rb", "test/test_resource.rb"]
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.homepage = %q{http://dm-sphinx.rubyforge.org}
|
16
16
|
s.rdoc_options = ["--main", "README.txt"]
|
@@ -26,13 +26,13 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
28
|
s.add_runtime_dependency(%q<dm-core>, ["~> 0.9.7"])
|
29
|
-
s.add_development_dependency(%q<hoe>, [">= 1.8.
|
29
|
+
s.add_development_dependency(%q<hoe>, [">= 1.8.3"])
|
30
30
|
else
|
31
31
|
s.add_dependency(%q<dm-core>, ["~> 0.9.7"])
|
32
|
-
s.add_dependency(%q<hoe>, [">= 1.8.
|
32
|
+
s.add_dependency(%q<hoe>, [">= 1.8.3"])
|
33
33
|
end
|
34
34
|
else
|
35
35
|
s.add_dependency(%q<dm-core>, ["~> 0.9.7"])
|
36
|
-
s.add_dependency(%q<hoe>, [">= 1.8.
|
36
|
+
s.add_dependency(%q<hoe>, [">= 1.8.3"])
|
37
37
|
end
|
38
38
|
end
|
data/lib/dm-sphinx-adapter.rb
CHANGED
@@ -36,9 +36,8 @@ module DataMapper
|
|
36
36
|
# uri_or_options<URI, DataObject::URI, Addressable::URI, String, Hash, Pathname>::
|
37
37
|
# DataMapper uri or options hash.
|
38
38
|
def initialize(name, uri_or_options)
|
39
|
-
|
40
|
-
@
|
41
|
-
options.each{|k, v| @client.method("#{k}=".to_sym).call(v) if @client.respond_to?("#{k}=".to_sym)}
|
39
|
+
super # Set up defaults.
|
40
|
+
@options = normalize_options(uri_or_options)
|
42
41
|
end
|
43
42
|
|
44
43
|
def create(resources) #:nodoc:
|
@@ -56,11 +55,13 @@ module DataMapper
|
|
56
55
|
# These methods are public but normally called indirectly through DataMapper::Resource#get,
|
57
56
|
# DataMapper::Resource#first or DataMapper::Resource#all.
|
58
57
|
#
|
58
|
+
# The document hashes returned are those from Riddle::Client.
|
59
|
+
#
|
59
60
|
# ==== Parameters
|
60
61
|
# query<DataMapper::Query>:: The query object.
|
61
62
|
#
|
62
63
|
# ==== Returns
|
63
|
-
# Array<Hash>:: An array of document hashes. <tt>[{:id => 1}, {:id => 2}]</tt>
|
64
|
+
# Array<Hash>:: An array of document hashes. <tt>[{:id => 1, ...}, {:id => 2, ...}]</tt>
|
64
65
|
# Array<>:: An empty array if no documents match.
|
65
66
|
def read_many(query)
|
66
67
|
read(query)
|
@@ -77,7 +78,7 @@ module DataMapper
|
|
77
78
|
# query<DataMapper::Query>:: The query object.
|
78
79
|
#
|
79
80
|
# ==== Returns
|
80
|
-
# Hash:: An document hash of the first document matched. <tt>{:id => 1}</tt>
|
81
|
+
# Hash:: An document hash of the first document matched. <tt>{:id => 1, ...}</tt>
|
81
82
|
# Nil:: If no documents match.
|
82
83
|
def read_one(query)
|
83
84
|
read(query).first
|
@@ -97,10 +98,10 @@ module DataMapper
|
|
97
98
|
#
|
98
99
|
# ==== Returns
|
99
100
|
# Array<DataMapper::Adapters::Sphinx::Index>:: Index objects from the model.
|
100
|
-
def indexes(
|
101
|
-
indexes = model.sphinx_indexes(
|
101
|
+
def indexes(query)
|
102
|
+
indexes = query.model.sphinx_indexes(name) if query.model.respond_to?(:sphinx_indexes)
|
102
103
|
if indexes.nil? or indexes.empty?
|
103
|
-
indexes = [Index.new(model, model.storage_name)]
|
104
|
+
indexes = [Index.new(query.model, query.model.storage_name(name))]
|
104
105
|
end
|
105
106
|
indexes
|
106
107
|
end
|
@@ -111,13 +112,18 @@ module DataMapper
|
|
111
112
|
# query<DataMapper::Query>:: The query object.
|
112
113
|
#
|
113
114
|
# ==== Returns
|
114
|
-
# Array<Hash>:: An array of document hashes. <tt>[{:id => 1}, {:id => 2}]</tt>
|
115
|
+
# Array<Hash>:: An array of document hashes. <tt>[{:id => 1, ...}, {:id => 2, ...}]</tt>
|
115
116
|
# Array<>:: An empty array if no documents match.
|
116
117
|
def read(query)
|
117
|
-
from
|
118
|
-
search
|
118
|
+
from = indexes(query).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
|
119
126
|
|
120
|
-
client = @client.dup
|
121
127
|
client.match_mode = :extended
|
122
128
|
client.filters = search_filters(query) # By attribute.
|
123
129
|
client.limit = query.limit.to_i if query.limit
|
@@ -134,7 +140,7 @@ module DataMapper
|
|
134
140
|
DataMapper.logger.info(
|
135
141
|
%q{Sphinx (%.3f): search '%s' in '%s' found %d documents} % [result[:time], search, from, result[:total]]
|
136
142
|
)
|
137
|
-
result[:matches].map{|doc|
|
143
|
+
result[:matches].map{|doc| doc[:id] = doc[:doc]; doc}
|
138
144
|
end
|
139
145
|
|
140
146
|
|
@@ -31,10 +31,11 @@ module DataMapper
|
|
31
31
|
query.conditions.each do |operator, property, value|
|
32
32
|
next if property.kind_of? Sphinx::Attribute # Filters are added elsewhere.
|
33
33
|
normalized = normalize_value(value)
|
34
|
+
field = property.field(query.repository.name) unless operator == :raw
|
34
35
|
@query << case operator
|
35
|
-
when :eql, :like then '@%s "%s"' % [
|
36
|
-
when :not then '@%s -"%s"' % [
|
37
|
-
when :in then '@%s (%s)' % [
|
36
|
+
when :eql, :like then '@%s "%s"' % [field.to_s, normalized.join(' ')]
|
37
|
+
when :not then '@%s -"%s"' % [field.to_s, normalized.join(' ')]
|
38
|
+
when :in then '@%s (%s)' % [field.to_s, normalized.map{|v| %{"#{v}"}}.join(' | ')]
|
38
39
|
when :raw then "#{property}"
|
39
40
|
else raise NotImplementedError.new("Sphinx: Query fields do not support the #{operator} operator")
|
40
41
|
end
|
data/test/files/model.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<sphinx:docset xmlns:sphinx="sphinx">
|
3
|
+
<sphinx:schema>
|
4
|
+
<sphinx:field name="t_string"/>
|
5
|
+
<sphinx:field name="t_text"/>
|
6
|
+
<sphinx:attr name="t_decimal" type="float"/>
|
7
|
+
<sphinx:attr name="t_float" type="float"/>
|
8
|
+
<sphinx:attr name="t_integer" type="int"/>
|
9
|
+
<sphinx:attr name="t_datetime" type="timestamp"/>
|
10
|
+
</sphinx:schema>
|
11
|
+
|
12
|
+
<sphinx:document id="1">
|
13
|
+
<t_string>one</t_string>
|
14
|
+
<t_text>text one!</t_text>
|
15
|
+
<t_decimal>10.5</t_decimal>
|
16
|
+
<t_float>100.5</t_float>
|
17
|
+
<t_integer>1000</t_integer>
|
18
|
+
<t_datetime>1235183682</t_datetime>
|
19
|
+
</sphinx:document>
|
20
|
+
|
21
|
+
<sphinx:document id="2">
|
22
|
+
<t_string>two</t_string>
|
23
|
+
<t_text>text two!</t_text>
|
24
|
+
<t_decimal>20.5</t_decimal>
|
25
|
+
<t_float>200.5</t_float>
|
26
|
+
<t_integer>2000</t_integer>
|
27
|
+
<t_datetime>1235183682</t_datetime>
|
28
|
+
</sphinx:document>
|
29
|
+
|
30
|
+
<sphinx:document id="3">
|
31
|
+
<t_string>three</t_string>
|
32
|
+
<t_text>text three!</t_text>
|
33
|
+
<t_decimal>30.5</t_decimal>
|
34
|
+
<t_float>300.5</t_float>
|
35
|
+
<t_integer>3000</t_integer>
|
36
|
+
<t_datetime>1235183682</t_datetime>
|
37
|
+
</sphinx:document>
|
38
|
+
</sphinx:docset>
|
39
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# searchd and indexer must be run from the root directory of this lib.
|
2
|
+
|
3
|
+
indexer
|
4
|
+
{
|
5
|
+
mem_limit = 64M
|
6
|
+
}
|
7
|
+
|
8
|
+
searchd
|
9
|
+
{
|
10
|
+
address = localhost
|
11
|
+
port = 3312
|
12
|
+
log = test/files/tmp/sphinx.log
|
13
|
+
query_log = test/files/tmp/sphinx.query.log
|
14
|
+
read_timeout = 5
|
15
|
+
pid_file = test/files/tmp/sphinx.pid
|
16
|
+
max_matches = 1000
|
17
|
+
}
|
18
|
+
|
19
|
+
source items
|
20
|
+
{
|
21
|
+
type = xmlpipe2
|
22
|
+
xmlpipe_command = cat test/files/source.xml
|
23
|
+
}
|
24
|
+
|
25
|
+
index items_main
|
26
|
+
{
|
27
|
+
source = items
|
28
|
+
charset_type = utf-8
|
29
|
+
path = test/files/tmp/items
|
30
|
+
}
|
31
|
+
|
32
|
+
index items
|
33
|
+
{
|
34
|
+
type = distributed
|
35
|
+
local = items_main
|
36
|
+
}
|
data/test/helper.rb
CHANGED
@@ -6,37 +6,32 @@ require 'pathname'
|
|
6
6
|
require 'shoulda'
|
7
7
|
require 'test/unit'
|
8
8
|
|
9
|
-
base
|
9
|
+
base = Pathname.new(__FILE__).dirname + '..'
|
10
|
+
files = base + 'test' + 'files'
|
10
11
|
%w{lib test}.each{|p| $:.unshift base + p}
|
11
12
|
|
12
13
|
require 'dm-sphinx-adapter'
|
13
14
|
|
14
15
|
# Sphinx runner.
|
15
16
|
Dir.chdir(base)
|
16
|
-
config = base + 'test' + 'files' + 'mysql5.sphinx.conf'
|
17
17
|
begin
|
18
18
|
TCPSocket.new('localhost', '3312')
|
19
19
|
rescue
|
20
20
|
puts 'Starting Sphinx...'
|
21
|
-
system("searchd --config #{
|
21
|
+
system("searchd --config #{files + 'sphinx.conf'}") || exit
|
22
22
|
system('ps aux | grep searchd')
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
before :setup do
|
29
|
-
files = Pathname.new(__FILE__).dirname + 'files'
|
30
|
-
|
31
|
-
mysql = `mysql5 dm_sphinx_adapter_test < #{files + 'mysql5.sql'} 2>&1`
|
32
|
-
raise %{Re-create database failed:\n #{mysql}} unless mysql.blank?
|
25
|
+
indexer = `indexer --config #{files + 'sphinx.conf'} --all --rotate`
|
26
|
+
raise %{Re-create index failed:\n #{indexer}} if indexer =~ /error|fatal/i
|
27
|
+
sleep 1
|
33
28
|
|
34
|
-
|
35
|
-
|
29
|
+
# :default is unused at the moment.
|
30
|
+
DataMapper.setup(:default, :adapter => 'in_memory', :database => 'dm_sphinx_adapter_test')
|
31
|
+
DataMapper.setup(:search, :adapter => 'sphinx')
|
36
32
|
|
37
|
-
|
38
|
-
|
39
|
-
end
|
33
|
+
class Test::Unit::TestCase
|
34
|
+
include Extlib::Hook
|
40
35
|
|
41
36
|
# after :teardown do
|
42
37
|
def teardown
|
data/test/test_adapter.rb
CHANGED
@@ -1,49 +1,52 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'helper')
|
2
2
|
|
3
3
|
class TestAdapter < Test::Unit::TestCase
|
4
|
-
context 'DM::A::Sphinx::Adapter
|
4
|
+
context 'DM::A::Sphinx::Adapter' do
|
5
5
|
setup do
|
6
|
-
DataMapper.setup(:adapter, :adapter => 'sphinx')
|
7
6
|
load File.join(File.dirname(__FILE__), 'files', 'model.rb')
|
8
|
-
@it = repository(:
|
7
|
+
@it = repository(:search)
|
9
8
|
@resource = Item
|
10
9
|
end
|
11
10
|
|
12
|
-
context '
|
13
|
-
should '
|
14
|
-
assert_equal
|
11
|
+
context 'class' do
|
12
|
+
should 'use default field naming convention' do
|
13
|
+
assert_equal(
|
14
|
+
DataMapper::NamingConventions::Field::Underscored,
|
15
|
+
@it.adapter.field_naming_convention
|
16
|
+
)
|
15
17
|
end
|
16
|
-
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
should 'use default resource naming convention' do
|
20
|
+
assert_equal(
|
21
|
+
DataMapper::NamingConventions::Resource::UnderscoredAndPluralized,
|
22
|
+
@it.adapter.resource_naming_convention
|
23
|
+
)
|
21
24
|
end
|
22
25
|
end
|
23
26
|
|
24
27
|
context '#read_many' do
|
25
28
|
context 'conditions' do
|
26
29
|
should 'return all objects when nil' do
|
27
|
-
assert_equal [
|
30
|
+
assert_equal [1, 2, 3], @it.read_many(query).map{|d| d[:id]}
|
28
31
|
end
|
29
32
|
|
30
33
|
should 'return subset of objects for conditions' do
|
31
|
-
assert_equal [
|
34
|
+
assert_equal [2], @it.read_many(query(:t_string => 'two')).map{|d| d[:id]}
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
35
38
|
context 'offsets' do
|
36
39
|
should 'be able to offset the objects' do
|
37
|
-
assert_equal [
|
38
|
-
assert_equal [
|
40
|
+
assert_equal [1, 2, 3], @it.read_many(query(:offset => 0)).map{|d| d[:id]}
|
41
|
+
assert_equal [2, 3], @it.read_many(query(:offset => 1)).map{|d| d[:id]}
|
39
42
|
assert_equal [], @it.read_many(query(:offset => 3))
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
43
46
|
context 'limits' do
|
44
47
|
should 'be able to limit the objects' do
|
45
|
-
assert_equal [
|
46
|
-
assert_equal [
|
48
|
+
assert_equal [1], @it.read_many(query(:limit => 1)).map{|d| d[:id]}
|
49
|
+
assert_equal [1, 2], @it.read_many(query(:limit => 2)).map{|d| d[:id]}
|
47
50
|
end
|
48
51
|
end
|
49
52
|
end
|
@@ -60,25 +63,6 @@ class TestAdapter < Test::Unit::TestCase
|
|
60
63
|
|
61
64
|
protected
|
62
65
|
def query(conditions = {})
|
63
|
-
DataMapper::Query.new(repository(:
|
64
|
-
end
|
65
|
-
|
66
|
-
def resource(options = {})
|
67
|
-
now = Time.now
|
68
|
-
attributes = {
|
69
|
-
:t_string => now.to_s,
|
70
|
-
:t_text => "text #{now.to_s}!",
|
71
|
-
:t_decimal => now.to_i * 0.001,
|
72
|
-
:t_float => now.to_i * 0.0001,
|
73
|
-
:t_integer => now.to_i,
|
74
|
-
:t_datetime => now
|
75
|
-
}.update(options)
|
76
|
-
@resource.new(attributes)
|
77
|
-
end
|
78
|
-
|
79
|
-
def create_resource(options = {})
|
80
|
-
repository(:adapter) do
|
81
|
-
@resource.create(resource(options).attributes.except(:id))
|
82
|
-
end
|
66
|
+
DataMapper::Query.new(repository(:search), @resource, conditions)
|
83
67
|
end
|
84
68
|
end
|
data/test/test_query.rb
CHANGED
@@ -3,9 +3,8 @@ require File.join(File.dirname(__FILE__), 'helper')
|
|
3
3
|
class TestQuery < Test::Unit::TestCase
|
4
4
|
context 'DM::A::Sphinx::Query conditions' do
|
5
5
|
setup do
|
6
|
-
DataMapper.setup(:adapter, :adapter => 'sphinx')
|
7
6
|
load File.join(File.dirname(__FILE__), 'files', 'model.rb')
|
8
|
-
@adapter = repository(:
|
7
|
+
@adapter = repository(:search)
|
9
8
|
@resource = Item
|
10
9
|
end
|
11
10
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-sphinx-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.7"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Hanna
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-02-22 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.8.
|
33
|
+
version: 1.8.3
|
34
34
|
version:
|
35
35
|
description: A DataMapper Sphinx adapter.
|
36
36
|
email:
|
@@ -63,8 +63,8 @@ files:
|
|
63
63
|
- lib/riddle/client/message.rb
|
64
64
|
- lib/riddle/client/response.rb
|
65
65
|
- test/files/model.rb
|
66
|
-
- test/files/
|
67
|
-
- test/files/
|
66
|
+
- test/files/source.xml
|
67
|
+
- test/files/sphinx.conf
|
68
68
|
- test/helper.rb
|
69
69
|
- test/test_adapter.rb
|
70
70
|
- test/test_attribute.rb
|
@@ -1,97 +0,0 @@
|
|
1
|
-
# searchd and indexer must be run from the root directory of this lib.
|
2
|
-
|
3
|
-
indexer
|
4
|
-
{
|
5
|
-
mem_limit = 64M
|
6
|
-
}
|
7
|
-
|
8
|
-
searchd
|
9
|
-
{
|
10
|
-
address = localhost
|
11
|
-
port = 3312
|
12
|
-
log = test/files/tmp/sphinx.log
|
13
|
-
query_log = test/files/tmp/sphinx.query.log
|
14
|
-
read_timeout = 5
|
15
|
-
pid_file = test/files/tmp/sphinx.pid
|
16
|
-
max_matches = 1000
|
17
|
-
}
|
18
|
-
|
19
|
-
source items
|
20
|
-
{
|
21
|
-
type = mysql
|
22
|
-
sql_host = localhost
|
23
|
-
sql_user = root
|
24
|
-
sql_pass =
|
25
|
-
sql_db = dm_sphinx_adapter_test
|
26
|
-
|
27
|
-
sql_query_pre = set names utf8
|
28
|
-
sql_query_pre = \
|
29
|
-
replace into delta (name, updated_on) ( \
|
30
|
-
select 'items', t_datetime \
|
31
|
-
from items \
|
32
|
-
order by t_datetime desc \
|
33
|
-
limit 1\
|
34
|
-
)
|
35
|
-
sql_query_info = select * from items where id = $id
|
36
|
-
|
37
|
-
sql_query_pre = set names utf8
|
38
|
-
sql_query = \
|
39
|
-
select \
|
40
|
-
id, \
|
41
|
-
t_string, \
|
42
|
-
t_text, \
|
43
|
-
t_decimal, \
|
44
|
-
t_float, \
|
45
|
-
t_integer, \
|
46
|
-
unix_timestamp(t_datetime) as t_datetime \
|
47
|
-
from items \
|
48
|
-
where t_datetime <= ( \
|
49
|
-
select updated_on \
|
50
|
-
from delta \
|
51
|
-
where name = 'items' \
|
52
|
-
)
|
53
|
-
|
54
|
-
sql_attr_float = t_decimal
|
55
|
-
sql_attr_float = t_float
|
56
|
-
sql_attr_uint = t_integer
|
57
|
-
sql_attr_timestamp = t_datetime
|
58
|
-
}
|
59
|
-
|
60
|
-
source items_delta : items {
|
61
|
-
sql_query_pre = set names utf8
|
62
|
-
sql_query_pre =
|
63
|
-
sql_query = \
|
64
|
-
select \
|
65
|
-
id, \
|
66
|
-
t_string, \
|
67
|
-
t_text, \
|
68
|
-
t_decimal, \
|
69
|
-
t_float, \
|
70
|
-
t_integer, \
|
71
|
-
unix_timestamp(t_datetime) as t_datetime \
|
72
|
-
from items \
|
73
|
-
where t_datetime > ( \
|
74
|
-
select updated_on \
|
75
|
-
from delta \
|
76
|
-
where name = 'items' \
|
77
|
-
)
|
78
|
-
}
|
79
|
-
|
80
|
-
index items_main
|
81
|
-
{
|
82
|
-
source = items
|
83
|
-
path = test/files/tmp/items_main
|
84
|
-
}
|
85
|
-
|
86
|
-
index items_delta : items_main
|
87
|
-
{
|
88
|
-
source = items_delta
|
89
|
-
path = test/files/tmp/items_delta
|
90
|
-
}
|
91
|
-
|
92
|
-
index items
|
93
|
-
{
|
94
|
-
type = distributed
|
95
|
-
local = items_main
|
96
|
-
local = items_delta
|
97
|
-
}
|
data/test/files/mysql5.sql
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
drop table if exists delta;
|
2
|
-
create table delta (
|
3
|
-
name varchar(50) not null,
|
4
|
-
updated_on datetime,
|
5
|
-
primary key (name)
|
6
|
-
) engine=innodb default charset=utf8;
|
7
|
-
|
8
|
-
insert into delta (name, updated_on) values
|
9
|
-
('items', now());
|
10
|
-
|
11
|
-
drop table if exists items;
|
12
|
-
create table items (
|
13
|
-
id int(11) not null auto_increment,
|
14
|
-
t_string varchar(50),
|
15
|
-
t_text text,
|
16
|
-
t_decimal decimal(30,10),
|
17
|
-
t_float float,
|
18
|
-
t_integer int,
|
19
|
-
t_datetime datetime,
|
20
|
-
primary key (id)
|
21
|
-
) engine=innodb default charset=utf8;
|
22
|
-
|
23
|
-
insert into items (t_string, t_text, t_decimal, t_float, t_integer, t_datetime) values
|
24
|
-
('one', 'text one!', '10.50', '100.50', '1000', now()),
|
25
|
-
('two', 'text two!', '20.50', '200.50', '2000', now()),
|
26
|
-
('three', 'text three!', '30.50', '300.50', '3000', now());
|