riddle 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +9 -0
- data/README.textile +1 -1
- data/lib/riddle/configuration.rb +4 -1
- data/lib/riddle/configuration/index.rb +6 -137
- data/lib/riddle/configuration/index_settings.rb +149 -0
- data/lib/riddle/configuration/parser.rb +29 -9
- data/lib/riddle/configuration/realtime_index.rb +15 -11
- data/lib/riddle/query/insert.rb +3 -1
- data/lib/riddle/query/select.rb +1 -1
- data/lib/riddle/version.rb +1 -1
- data/riddle.gemspec +1 -1
- data/spec/riddle/query/select_spec.rb +5 -0
- data/spec/unit/configuration/index_spec.rb +13 -13
- data/spec/unit/configuration/realtime_index_spec.rb +8 -8
- metadata +15 -13
data/HISTORY
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
1.5.4 - January 2nd 2013
|
2
|
+
- RT indices get most of the same settings as SQL indices.
|
3
|
+
- Escape single quotes in SphinxQL match queries, given we're wrapping them in single quotes.
|
4
|
+
- Remove unnecessary characters from string values for SphinxQL inserts.
|
5
|
+
- Convert time objects to integers for SphinxQL inserts.
|
6
|
+
- Include 'orphan' sources (which aren't used directly by indices, but could be parents of sources that are used) when generating configuration files.
|
7
|
+
- Use parent source type if child source has no type supplied.
|
8
|
+
- Ignore comments when parsing Sphinx configuration files.
|
9
|
+
|
1
10
|
1.5.3 - August 10th 2012
|
2
11
|
- Sphinx 2.0.5 support.
|
3
12
|
- :with_all and :without_all support for SphinxQL.
|
data/README.textile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
h1. Riddle
|
2
2
|
|
3
|
-
"!https://secure.travis-ci.org/
|
3
|
+
"!https://secure.travis-ci.org/pat/riddle.png!":http://travis-ci.org/pat/riddle
|
4
4
|
|
5
5
|
This client has been written to interface with "Sphinx":http://sphinxsearch.com/. It is written by "Pat Allan":http://freelancing-gods.com, and has been influenced by both Dmytro Shteflyuk's Ruby client and the original PHP client - credit where credit's due, after all.
|
6
6
|
|
data/lib/riddle/configuration.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'riddle/configuration/section'
|
2
|
+
require 'riddle/configuration/index_settings'
|
2
3
|
|
3
4
|
require 'riddle/configuration/distributed_index'
|
4
5
|
require 'riddle/configuration/index'
|
@@ -17,7 +18,7 @@ module Riddle
|
|
17
18
|
class ConfigurationError < StandardError #:nodoc:
|
18
19
|
end
|
19
20
|
|
20
|
-
attr_reader :indices, :searchd
|
21
|
+
attr_reader :indices, :searchd, :sources
|
21
22
|
attr_accessor :indexer
|
22
23
|
|
23
24
|
def self.parse!(input)
|
@@ -28,11 +29,13 @@ module Riddle
|
|
28
29
|
@indexer = Riddle::Configuration::Indexer.new
|
29
30
|
@searchd = Riddle::Configuration::Searchd.new
|
30
31
|
@indices = []
|
32
|
+
@sources = []
|
31
33
|
end
|
32
34
|
|
33
35
|
def render
|
34
36
|
(
|
35
37
|
[@indexer.render, @searchd.render] +
|
38
|
+
@sources.collect { |source| source.render } +
|
36
39
|
@indices.collect { |index| index.render }
|
37
40
|
).join("\n")
|
38
41
|
end
|
@@ -1,142 +1,25 @@
|
|
1
1
|
module Riddle
|
2
2
|
class Configuration
|
3
3
|
class Index < Riddle::Configuration::Section
|
4
|
+
include Riddle::Configuration::IndexSettings
|
5
|
+
|
4
6
|
def self.settings
|
5
|
-
[
|
6
|
-
:type, :source, :path, :docinfo, :mlock, :morphology,
|
7
|
-
:dict, :index_sp, :index_zones, :min_stemming_len, :stopwords,
|
8
|
-
:wordforms, :exceptions, :min_word_len, :charset_dictpath,
|
9
|
-
:charset_type, :charset_table, :ignore_chars, :min_prefix_len,
|
10
|
-
:min_infix_len, :prefix_fields, :infix_fields, :enable_star,
|
11
|
-
:expand_keywords, :ngram_len, :ngram_chars, :phrase_boundary,
|
12
|
-
:phrase_boundary_step, :blend_chars, :blend_mode, :html_strip,
|
13
|
-
:html_index_attrs, :html_remove_elements, :preopen, :ondisk_dict,
|
14
|
-
:inplace_enable, :inplace_hit_gap, :inplace_docinfo_gap,
|
15
|
-
:inplace_reloc_factor, :inplace_write_factor, :index_exact_words,
|
16
|
-
:overshort_step, :stopwords_step, :hitless_words
|
17
|
-
]
|
7
|
+
Riddle::Configuration::IndexSettings.settings + [:source]
|
18
8
|
end
|
19
9
|
|
20
|
-
attr_accessor :
|
21
|
-
:morphologies, :dict, :index_sp, :index_zones, :min_stemming_len,
|
22
|
-
:stopword_files, :wordform_files, :exception_files, :min_word_len,
|
23
|
-
:charset_dictpath, :charset_type, :charset_table, :ignore_characters,
|
24
|
-
:min_prefix_len, :min_infix_len, :prefix_field_names,
|
25
|
-
:infix_field_names, :enable_star, :expand_keywords, :ngram_len,
|
26
|
-
:ngram_characters, :phrase_boundaries, :phrase_boundary_step,
|
27
|
-
:blend_chars, :blend_mode, :html_strip, :html_index_attrs,
|
28
|
-
:html_remove_element_tags, :preopen, :ondisk_dict, :inplace_enable,
|
29
|
-
:inplace_hit_gap, :inplace_docinfo_gap, :inplace_reloc_factor,
|
30
|
-
:inplace_write_factor, :index_exact_words, :overshort_step,
|
31
|
-
:stopwords_step, :hitless_words
|
10
|
+
attr_accessor :parent, :sources
|
32
11
|
|
33
12
|
def initialize(name, *sources)
|
34
13
|
@name = name
|
35
14
|
@sources = sources
|
36
|
-
|
37
|
-
|
38
|
-
@wordform_files = []
|
39
|
-
@exception_files = []
|
40
|
-
@ignore_characters = []
|
41
|
-
@prefix_field_names = []
|
42
|
-
@infix_field_names = []
|
43
|
-
@ngram_characters = []
|
44
|
-
@phrase_boundaries = []
|
45
|
-
@html_remove_element_tags = []
|
15
|
+
|
16
|
+
initialize_settings
|
46
17
|
end
|
47
18
|
|
48
19
|
def source
|
49
20
|
@sources.collect { |s| s.name }
|
50
21
|
end
|
51
22
|
|
52
|
-
def morphology
|
53
|
-
nil_join @morphologies, ", "
|
54
|
-
end
|
55
|
-
|
56
|
-
def morphology=(morphology)
|
57
|
-
@morphologies = nil_split morphology, /,\s?/
|
58
|
-
end
|
59
|
-
|
60
|
-
def stopwords
|
61
|
-
nil_join @stopword_files, " "
|
62
|
-
end
|
63
|
-
|
64
|
-
def stopwords=(stopwords)
|
65
|
-
@stopword_files = nil_split stopwords, ' '
|
66
|
-
end
|
67
|
-
|
68
|
-
def wordforms
|
69
|
-
nil_join @wordform_files, " "
|
70
|
-
end
|
71
|
-
|
72
|
-
def wordforms=(wordforms)
|
73
|
-
@wordform_files = nil_split wordforms, ' '
|
74
|
-
end
|
75
|
-
|
76
|
-
def exceptions
|
77
|
-
nil_join @exception_files, " "
|
78
|
-
end
|
79
|
-
|
80
|
-
def exceptions=(exceptions)
|
81
|
-
@exception_files = nil_split exceptions, ' '
|
82
|
-
end
|
83
|
-
|
84
|
-
def ignore_chars
|
85
|
-
nil_join @ignore_characters, ", "
|
86
|
-
end
|
87
|
-
|
88
|
-
def ignore_chars=(ignore_chars)
|
89
|
-
@ignore_characters = nil_split ignore_chars, /,\s?/
|
90
|
-
end
|
91
|
-
|
92
|
-
def prefix_fields
|
93
|
-
nil_join @prefix_field_names, ", "
|
94
|
-
end
|
95
|
-
|
96
|
-
def prefix_fields=(fields)
|
97
|
-
if fields.is_a?(Array)
|
98
|
-
@prefix_field_names = fields
|
99
|
-
else
|
100
|
-
@prefix_field_names = fields.split(/,\s*/)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def infix_fields
|
105
|
-
nil_join @infix_field_names, ", "
|
106
|
-
end
|
107
|
-
|
108
|
-
def infix_fields=(fields)
|
109
|
-
if fields.is_a?(Array)
|
110
|
-
@infix_field_names = fields
|
111
|
-
else
|
112
|
-
@infix_field_names = fields.split(/,\s*/)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
def ngram_chars
|
117
|
-
nil_join @ngram_characters, ", "
|
118
|
-
end
|
119
|
-
|
120
|
-
def ngram_chars=(ngram_chars)
|
121
|
-
@ngram_characters = nil_split ngram_chars, /,\s?/
|
122
|
-
end
|
123
|
-
|
124
|
-
def phrase_boundary
|
125
|
-
nil_join @phrase_boundaries, ", "
|
126
|
-
end
|
127
|
-
|
128
|
-
def phrase_boundary=(phrase_boundary)
|
129
|
-
@phrase_boundaries = nil_split phrase_boundary, /,\s?/
|
130
|
-
end
|
131
|
-
|
132
|
-
def html_remove_elements
|
133
|
-
nil_join @html_remove_element_tags, ", "
|
134
|
-
end
|
135
|
-
|
136
|
-
def html_remove_elements=(html_remove_elements)
|
137
|
-
@html_remove_element_tags = nil_split html_remove_elements, /,\s?/
|
138
|
-
end
|
139
|
-
|
140
23
|
def render
|
141
24
|
raise ConfigurationError, "#{@name} #{@sources.inspect} #{@path} #{@parent}" unless valid?
|
142
25
|
|
@@ -153,20 +36,6 @@ module Riddle
|
|
153
36
|
def valid?
|
154
37
|
(!@name.nil?) && (!( @sources.length == 0 || @path.nil? ) || !@parent.nil?)
|
155
38
|
end
|
156
|
-
|
157
|
-
private
|
158
|
-
|
159
|
-
def nil_split(string, pattern)
|
160
|
-
(string || "").split(pattern)
|
161
|
-
end
|
162
|
-
|
163
|
-
def nil_join(array, delimiter)
|
164
|
-
if array.length == 0
|
165
|
-
nil
|
166
|
-
else
|
167
|
-
array.join(delimiter)
|
168
|
-
end
|
169
|
-
end
|
170
39
|
end
|
171
40
|
end
|
172
41
|
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
module Riddle
|
2
|
+
class Configuration
|
3
|
+
module IndexSettings
|
4
|
+
def self.settings
|
5
|
+
[
|
6
|
+
:type, :path, :docinfo, :mlock, :morphology,
|
7
|
+
:dict, :index_sp, :index_zones, :min_stemming_len, :stopwords,
|
8
|
+
:wordforms, :exceptions, :min_word_len, :charset_dictpath,
|
9
|
+
:charset_type, :charset_table, :ignore_chars, :min_prefix_len,
|
10
|
+
:min_infix_len, :prefix_fields, :infix_fields, :enable_star,
|
11
|
+
:expand_keywords, :ngram_len, :ngram_chars, :phrase_boundary,
|
12
|
+
:phrase_boundary_step, :blend_chars, :blend_mode, :html_strip,
|
13
|
+
:html_index_attrs, :html_remove_elements, :preopen, :ondisk_dict,
|
14
|
+
:inplace_enable, :inplace_hit_gap, :inplace_docinfo_gap,
|
15
|
+
:inplace_reloc_factor, :inplace_write_factor, :index_exact_words,
|
16
|
+
:overshort_step, :stopwords_step, :hitless_words
|
17
|
+
]
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_accessor :name, :type, :path, :docinfo, :mlock,
|
21
|
+
:morphologies, :dict, :index_sp, :index_zones, :min_stemming_len,
|
22
|
+
:stopword_files, :wordform_files, :exception_files, :min_word_len,
|
23
|
+
:charset_dictpath, :charset_type, :charset_table, :ignore_characters,
|
24
|
+
:min_prefix_len, :min_infix_len, :prefix_field_names,
|
25
|
+
:infix_field_names, :enable_star, :expand_keywords, :ngram_len,
|
26
|
+
:ngram_characters, :phrase_boundaries, :phrase_boundary_step,
|
27
|
+
:blend_chars, :blend_mode, :html_strip, :html_index_attrs,
|
28
|
+
:html_remove_element_tags, :preopen, :ondisk_dict, :inplace_enable,
|
29
|
+
:inplace_hit_gap, :inplace_docinfo_gap, :inplace_reloc_factor,
|
30
|
+
:inplace_write_factor, :index_exact_words, :overshort_step,
|
31
|
+
:stopwords_step, :hitless_words
|
32
|
+
|
33
|
+
def initialize_settings
|
34
|
+
@morphologies = []
|
35
|
+
@stopword_files = []
|
36
|
+
@wordform_files = []
|
37
|
+
@exception_files = []
|
38
|
+
@ignore_characters = []
|
39
|
+
@prefix_field_names = []
|
40
|
+
@infix_field_names = []
|
41
|
+
@ngram_characters = []
|
42
|
+
@phrase_boundaries = []
|
43
|
+
@html_remove_element_tags = []
|
44
|
+
end
|
45
|
+
|
46
|
+
def morphology
|
47
|
+
nil_join @morphologies, ", "
|
48
|
+
end
|
49
|
+
|
50
|
+
def morphology=(morphology)
|
51
|
+
@morphologies = nil_split morphology, /,\s?/
|
52
|
+
end
|
53
|
+
|
54
|
+
def stopwords
|
55
|
+
nil_join @stopword_files, " "
|
56
|
+
end
|
57
|
+
|
58
|
+
def stopwords=(stopwords)
|
59
|
+
@stopword_files = nil_split stopwords, ' '
|
60
|
+
end
|
61
|
+
|
62
|
+
def wordforms
|
63
|
+
nil_join @wordform_files, " "
|
64
|
+
end
|
65
|
+
|
66
|
+
def wordforms=(wordforms)
|
67
|
+
@wordform_files = nil_split wordforms, ' '
|
68
|
+
end
|
69
|
+
|
70
|
+
def exceptions
|
71
|
+
nil_join @exception_files, " "
|
72
|
+
end
|
73
|
+
|
74
|
+
def exceptions=(exceptions)
|
75
|
+
@exception_files = nil_split exceptions, ' '
|
76
|
+
end
|
77
|
+
|
78
|
+
def ignore_chars
|
79
|
+
nil_join @ignore_characters, ", "
|
80
|
+
end
|
81
|
+
|
82
|
+
def ignore_chars=(ignore_chars)
|
83
|
+
@ignore_characters = nil_split ignore_chars, /,\s?/
|
84
|
+
end
|
85
|
+
|
86
|
+
def prefix_fields
|
87
|
+
nil_join @prefix_field_names, ", "
|
88
|
+
end
|
89
|
+
|
90
|
+
def prefix_fields=(fields)
|
91
|
+
if fields.is_a?(Array)
|
92
|
+
@prefix_field_names = fields
|
93
|
+
else
|
94
|
+
@prefix_field_names = fields.split(/,\s*/)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def infix_fields
|
99
|
+
nil_join @infix_field_names, ", "
|
100
|
+
end
|
101
|
+
|
102
|
+
def infix_fields=(fields)
|
103
|
+
if fields.is_a?(Array)
|
104
|
+
@infix_field_names = fields
|
105
|
+
else
|
106
|
+
@infix_field_names = fields.split(/,\s*/)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def ngram_chars
|
111
|
+
nil_join @ngram_characters, ", "
|
112
|
+
end
|
113
|
+
|
114
|
+
def ngram_chars=(ngram_chars)
|
115
|
+
@ngram_characters = nil_split ngram_chars, /,\s?/
|
116
|
+
end
|
117
|
+
|
118
|
+
def phrase_boundary
|
119
|
+
nil_join @phrase_boundaries, ", "
|
120
|
+
end
|
121
|
+
|
122
|
+
def phrase_boundary=(phrase_boundary)
|
123
|
+
@phrase_boundaries = nil_split phrase_boundary, /,\s?/
|
124
|
+
end
|
125
|
+
|
126
|
+
def html_remove_elements
|
127
|
+
nil_join @html_remove_element_tags, ", "
|
128
|
+
end
|
129
|
+
|
130
|
+
def html_remove_elements=(html_remove_elements)
|
131
|
+
@html_remove_element_tags = nil_split html_remove_elements, /,\s?/
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
def nil_split(string, pattern)
|
137
|
+
(string || "").split(pattern)
|
138
|
+
end
|
139
|
+
|
140
|
+
def nil_join(array, delimiter)
|
141
|
+
if array.length == 0
|
142
|
+
nil
|
143
|
+
else
|
144
|
+
array.join(delimiter)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -27,11 +27,24 @@ class Riddle::Configuration::Parser
|
|
27
27
|
set_sources
|
28
28
|
set_indices
|
29
29
|
|
30
|
+
add_orphan_sources
|
31
|
+
|
30
32
|
configuration
|
31
33
|
end
|
32
34
|
|
33
35
|
private
|
34
36
|
|
37
|
+
def add_orphan_sources
|
38
|
+
all_names = sources.keys
|
39
|
+
attached_names = configuration.indices.collect { |index|
|
40
|
+
index.respond_to?(:sources) ? index.sources.collect(&:name) : []
|
41
|
+
}.flatten
|
42
|
+
|
43
|
+
(all_names - attached_names).each do |name|
|
44
|
+
configuration.sources << sources[name]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
35
48
|
def inner
|
36
49
|
@inner ||= InnerParser.new(@input).parse!
|
37
50
|
end
|
@@ -46,7 +59,7 @@ class Riddle::Configuration::Parser
|
|
46
59
|
|
47
60
|
def each_with_prefix(prefix)
|
48
61
|
inner.keys.select { |key| key[/^#{prefix}\s+/] }.each do |key|
|
49
|
-
yield key.gsub(/^#{prefix}\s+/, ''), inner[key]
|
62
|
+
yield key.gsub(/^#{prefix}\s+/, '').gsub(/\s*{$/, ''), inner[key]
|
50
63
|
end
|
51
64
|
end
|
52
65
|
|
@@ -60,10 +73,14 @@ class Riddle::Configuration::Parser
|
|
60
73
|
|
61
74
|
def set_sources
|
62
75
|
each_with_prefix 'source' do |name, settings|
|
63
|
-
names
|
64
|
-
|
76
|
+
names = name.split(/\s*:\s*/)
|
77
|
+
types = settings.delete('type')
|
78
|
+
parent = names.length > 1 ? names.last : nil
|
79
|
+
types ||= [sources[parent].type] if parent
|
80
|
+
type = types.first
|
81
|
+
|
65
82
|
source = SOURCE_CLASSES[type].new names.first, type
|
66
|
-
source.parent =
|
83
|
+
source.parent = parent
|
67
84
|
|
68
85
|
set_settings source, settings
|
69
86
|
|
@@ -139,11 +156,14 @@ class Riddle::Configuration::Parser
|
|
139
156
|
|
140
157
|
while line != '}' do
|
141
158
|
begin
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
159
|
+
match = SETTING_PATTERN.match(line)
|
160
|
+
unless match.nil?
|
161
|
+
key, value = *match.captures
|
162
|
+
settings[key] << value
|
163
|
+
while value[/\\$/] do
|
164
|
+
value = next_line
|
165
|
+
settings[key].last << "\n" << value
|
166
|
+
end
|
147
167
|
end
|
148
168
|
rescue => error
|
149
169
|
raise error, "Error handling line '#{line}': #{error.message}",
|
@@ -1,16 +1,18 @@
|
|
1
1
|
module Riddle
|
2
2
|
class Configuration
|
3
3
|
class RealtimeIndex < Riddle::Configuration::Section
|
4
|
+
include Riddle::Configuration::IndexSettings
|
5
|
+
|
4
6
|
def self.settings
|
5
|
-
[
|
6
|
-
:
|
7
|
-
:
|
7
|
+
Riddle::Configuration::IndexSettings.settings + [
|
8
|
+
:rt_mem_limit, :rt_field, :rt_attr_uint, :rt_attr_bigint,
|
9
|
+
:rt_attr_float, :rt_attr_timestamp, :rt_attr_string
|
8
10
|
]
|
9
11
|
end
|
10
|
-
|
11
|
-
attr_accessor :
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
attr_accessor :rt_mem_limit, :rt_field, :rt_attr_uint, :rt_attr_bigint,
|
14
|
+
:rt_attr_float, :rt_attr_timestamp, :rt_attr_string
|
15
|
+
|
14
16
|
def initialize(name)
|
15
17
|
@name = name
|
16
18
|
@rt_field = []
|
@@ -19,19 +21,21 @@ module Riddle
|
|
19
21
|
@rt_attr_float = []
|
20
22
|
@rt_attr_timestamp = []
|
21
23
|
@rt_attr_string = []
|
24
|
+
|
25
|
+
initialize_settings
|
22
26
|
end
|
23
|
-
|
27
|
+
|
24
28
|
def type
|
25
29
|
"rt"
|
26
30
|
end
|
27
|
-
|
31
|
+
|
28
32
|
def valid?
|
29
33
|
!(@name.nil? || @path.nil?)
|
30
34
|
end
|
31
|
-
|
35
|
+
|
32
36
|
def render
|
33
37
|
raise ConfigurationError unless valid?
|
34
|
-
|
38
|
+
|
35
39
|
(
|
36
40
|
["index #{name}", "{"] +
|
37
41
|
settings_body +
|
data/lib/riddle/query/insert.rb
CHANGED
@@ -38,9 +38,11 @@ class Riddle::Query::Insert
|
|
38
38
|
def translated_value(value)
|
39
39
|
case value
|
40
40
|
when String
|
41
|
-
"'#{value}'"
|
41
|
+
"'#{value.gsub(/['\\]/, '').gsub(/\s+/, ' ')}'"
|
42
42
|
when TrueClass, FalseClass
|
43
43
|
value ? 1 : 0
|
44
|
+
when Time
|
45
|
+
value.to_i
|
44
46
|
else
|
45
47
|
value
|
46
48
|
end
|
data/lib/riddle/query/select.rb
CHANGED
data/lib/riddle/version.rb
CHANGED
data/riddle.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ['Pat Allan']
|
10
10
|
s.email = ['pat@freelancing-gods.com']
|
11
|
-
s.homepage = 'http://
|
11
|
+
s.homepage = 'http://pat.github.com/riddle/'
|
12
12
|
s.summary = %q{An API for Sphinx, written in and for Ruby.}
|
13
13
|
s.description = %q{A Ruby API and configuration helper for the Sphinx search service.}
|
14
14
|
|
@@ -26,6 +26,11 @@ describe Riddle::Query::Select do
|
|
26
26
|
query.from('foo_core').matching('foo').to_sql.
|
27
27
|
should == "SELECT * FROM foo_core WHERE MATCH('foo')"
|
28
28
|
end
|
29
|
+
|
30
|
+
it "escapes single quotes in the search terms" do
|
31
|
+
query.from('foo_core').matching("fo'o").to_sql.
|
32
|
+
should == "SELECT * FROM foo_core WHERE MATCH('fo\\'o')"
|
33
|
+
end
|
29
34
|
|
30
35
|
it 'handles filters with integers' do
|
31
36
|
query.from('foo_core').matching('foo').where(:bar_id => 10).to_sql.
|
@@ -4,44 +4,44 @@ describe Riddle::Configuration::DistributedIndex do
|
|
4
4
|
it "should be invalid without a name, sources or path if there's no parent" do
|
5
5
|
index = Riddle::Configuration::Index.new(nil)
|
6
6
|
index.should_not be_valid
|
7
|
-
|
7
|
+
|
8
8
|
index.name = "test1"
|
9
9
|
index.should_not be_valid
|
10
|
-
|
10
|
+
|
11
11
|
index.sources << Riddle::Configuration::SQLSource.new("source", "mysql")
|
12
12
|
index.should_not be_valid
|
13
|
-
|
13
|
+
|
14
14
|
index.path = "a/path"
|
15
15
|
index.should be_valid
|
16
|
-
|
16
|
+
|
17
17
|
index.name = nil
|
18
18
|
index.should_not be_valid
|
19
|
-
|
19
|
+
|
20
20
|
index.name = "test1"
|
21
21
|
index.sources.clear
|
22
22
|
index.should_not be_valid
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it "should be invalid without a name but not sources or path if it has a parent" do
|
26
26
|
index = Riddle::Configuration::Index.new(nil)
|
27
27
|
index.should_not be_valid
|
28
|
-
|
28
|
+
|
29
29
|
index.name = "test1stemmed"
|
30
30
|
index.should_not be_valid
|
31
|
-
|
31
|
+
|
32
32
|
index.parent = "test1"
|
33
33
|
index.should be_valid
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
it "should raise a ConfigurationError if rendering when not valid" do
|
37
37
|
index = Riddle::Configuration::Index.new("test1")
|
38
38
|
lambda { index.render }.should raise_error(Riddle::Configuration::ConfigurationError)
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
it "should render correctly if supplied settings are valid" do
|
42
42
|
source = Riddle::Configuration::XMLSource.new("src1", "xmlpipe")
|
43
43
|
source.xmlpipe_command = "ls /dev/null"
|
44
|
-
|
44
|
+
|
45
45
|
index = Riddle::Configuration::Index.new("test1", source)
|
46
46
|
index.path = "/var/data/test1"
|
47
47
|
index.docinfo = "extern"
|
@@ -75,7 +75,7 @@ describe Riddle::Configuration::DistributedIndex do
|
|
75
75
|
index.inplace_reloc_factor = 0.1
|
76
76
|
index.inplace_write_factor = 0.1
|
77
77
|
index.index_exact_words = 1
|
78
|
-
|
78
|
+
|
79
79
|
index.render.should == <<-INDEX
|
80
80
|
source src1
|
81
81
|
{
|
@@ -85,7 +85,6 @@ source src1
|
|
85
85
|
|
86
86
|
index test1
|
87
87
|
{
|
88
|
-
source = src1
|
89
88
|
path = /var/data/test1
|
90
89
|
docinfo = extern
|
91
90
|
mlock = 0
|
@@ -118,6 +117,7 @@ index test1
|
|
118
117
|
inplace_reloc_factor = 0.1
|
119
118
|
inplace_write_factor = 0.1
|
120
119
|
index_exact_words = 1
|
120
|
+
source = src1
|
121
121
|
}
|
122
122
|
INDEX
|
123
123
|
end
|
@@ -2,49 +2,49 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Riddle::Configuration::RealtimeIndex do
|
4
4
|
let(:index) { Riddle::Configuration::RealtimeIndex.new('rt1') }
|
5
|
-
|
5
|
+
|
6
6
|
describe '#valid?' do
|
7
7
|
it "should not be valid without a name" do
|
8
8
|
index.name = nil
|
9
9
|
index.path = 'foo'
|
10
10
|
index.should_not be_valid
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should not be valid without a path" do
|
14
14
|
index.path = nil
|
15
15
|
index.should_not be_valid
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should be valid with a name and path" do
|
19
19
|
index.path = 'foo'
|
20
20
|
index.should be_valid
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
describe '#type' do
|
25
25
|
it "should be 'rt'" do
|
26
26
|
index.type.should == 'rt'
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
describe '#render' do
|
31
31
|
it "should raise a ConfigurationError if rendering when not valid" do
|
32
32
|
lambda {
|
33
33
|
index.render
|
34
34
|
}.should raise_error(Riddle::Configuration::ConfigurationError)
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it "should render correctly if supplied settings are valid" do
|
38
38
|
index.path = '/var/data/rt'
|
39
39
|
index.rt_mem_limit = '512M'
|
40
40
|
index.rt_field << 'title' << 'content'
|
41
|
-
|
41
|
+
|
42
42
|
index.rt_attr_uint << 'gid'
|
43
43
|
index.rt_attr_bigint << 'guid'
|
44
44
|
index.rt_attr_float << 'gpa'
|
45
45
|
index.rt_attr_timestamp << 'ts_added'
|
46
46
|
index.rt_attr_string << 'author'
|
47
|
-
|
47
|
+
|
48
48
|
index.render.should == <<-RTINDEX
|
49
49
|
index rt1
|
50
50
|
{
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riddle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 1.5.
|
9
|
+
- 4
|
10
|
+
version: 1.5.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pat Allan
|
@@ -15,10 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2013-01-02 00:00:00 +11:00
|
19
|
+
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
type: :development
|
22
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
23
|
none: false
|
24
24
|
requirements:
|
@@ -31,10 +31,10 @@ dependencies:
|
|
31
31
|
- 2
|
32
32
|
version: 0.9.2
|
33
33
|
version_requirements: *id001
|
34
|
-
prerelease: false
|
35
34
|
name: rake
|
36
|
-
|
35
|
+
prerelease: false
|
37
36
|
type: :development
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
@@ -47,10 +47,10 @@ dependencies:
|
|
47
47
|
- 0
|
48
48
|
version: 2.5.0
|
49
49
|
version_requirements: *id002
|
50
|
-
prerelease: false
|
51
50
|
name: rspec
|
52
|
-
|
51
|
+
prerelease: false
|
53
52
|
type: :development
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
55
|
none: false
|
56
56
|
requirements:
|
@@ -63,8 +63,9 @@ dependencies:
|
|
63
63
|
- 2
|
64
64
|
version: 0.7.2
|
65
65
|
version_requirements: *id003
|
66
|
-
prerelease: false
|
67
66
|
name: yard
|
67
|
+
prerelease: false
|
68
|
+
type: :development
|
68
69
|
description: A Ruby API and configuration helper for the Sphinx search service.
|
69
70
|
email:
|
70
71
|
- pat@freelancing-gods.com
|
@@ -101,6 +102,7 @@ files:
|
|
101
102
|
- lib/riddle/configuration.rb
|
102
103
|
- lib/riddle/configuration/distributed_index.rb
|
103
104
|
- lib/riddle/configuration/index.rb
|
105
|
+
- lib/riddle/configuration/index_settings.rb
|
104
106
|
- lib/riddle/configuration/indexer.rb
|
105
107
|
- lib/riddle/configuration/parser.rb
|
106
108
|
- lib/riddle/configuration/realtime_index.rb
|
@@ -275,7 +277,8 @@ files:
|
|
275
277
|
- spec/unit/message_spec.rb
|
276
278
|
- spec/unit/response_spec.rb
|
277
279
|
- spec/unit/riddle_spec.rb
|
278
|
-
|
280
|
+
has_rdoc: true
|
281
|
+
homepage: http://pat.github.com/riddle/
|
279
282
|
licenses: []
|
280
283
|
|
281
284
|
post_install_message:
|
@@ -304,7 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
304
307
|
requirements: []
|
305
308
|
|
306
309
|
rubyforge_project: riddle
|
307
|
-
rubygems_version: 1.
|
310
|
+
rubygems_version: 1.6.2
|
308
311
|
signing_key:
|
309
312
|
specification_version: 3
|
310
313
|
summary: An API for Sphinx, written in and for Ruby.
|
@@ -467,4 +470,3 @@ test_files:
|
|
467
470
|
- spec/unit/message_spec.rb
|
468
471
|
- spec/unit/response_spec.rb
|
469
472
|
- spec/unit/riddle_spec.rb
|
470
|
-
has_rdoc:
|