picky 4.3.2 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/picky/query/allocation.rb +18 -4
- data/lib/picky/query/allocations.rb +7 -4
- data/lib/picky/results.rb +4 -4
- data/lib/picky/search.rb +11 -6
- data/lib/picky.rb +8 -0
- data/spec/functional/backends/memory_json_utf8_spec.rb +18 -0
- data/spec/functional/unique_ids_search_spec.rb +54 -0
- data/spec/lib/picky_spec.rb +14 -0
- data/spec/lib/query/allocation_spec.rb +26 -0
- data/spec/lib/query/allocations_spec.rb +41 -34
- data/spec/lib/search_spec.rb +9 -2
- metadata +23 -17
@@ -63,10 +63,24 @@ module Picky
|
|
63
63
|
#
|
64
64
|
# Returns the calculated ids (from the offset).
|
65
65
|
#
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
# Parameters:
|
67
|
+
# * amount: The amount of ids to calculate.
|
68
|
+
# * offset: The offset to calculate them from.
|
69
|
+
# * illegal_ids: ids to ignore.
|
70
|
+
#
|
71
|
+
def process! amount, offset, illegal_ids = nil
|
72
|
+
if illegal_ids
|
73
|
+
# Note: Fairly inefficient calculation since it
|
74
|
+
# assumes the worst case that the ids contain
|
75
|
+
# all illegal ids.
|
76
|
+
#
|
77
|
+
calculated_ids = calculate_ids amount + illegal_ids.size, offset
|
78
|
+
calculated_ids = calculated_ids - illegal_ids
|
79
|
+
else
|
80
|
+
calculated_ids = calculate_ids amount, offset
|
81
|
+
end
|
82
|
+
@count = calculated_ids.size # cache the count before throwing away the ids
|
83
|
+
@ids = calculated_ids.slice!(offset, amount) || [] # slice out the relevant part
|
70
84
|
end
|
71
85
|
|
72
86
|
#
|
@@ -63,6 +63,7 @@ module Picky
|
|
63
63
|
# * amount: the amount of ids to calculate
|
64
64
|
# * offset: the offset from where in the result set to take the ids
|
65
65
|
# * terminate_early: Whether to calculate all allocations.
|
66
|
+
# * unique: If ids have already been found, do not find them anymore (if true)
|
66
67
|
#
|
67
68
|
# Note: With an amount of 0, an offset > 0 doesn't make much
|
68
69
|
# sense, as seen in the live search.
|
@@ -72,19 +73,21 @@ module Picky
|
|
72
73
|
#
|
73
74
|
# Note: It's possible that no ids are returned by an allocation, but a count. (In case of an offset)
|
74
75
|
#
|
75
|
-
def process! amount, offset = 0, terminate_early = nil
|
76
|
+
def process! amount, offset = 0, terminate_early = nil, unique = false
|
77
|
+
unique_ids = nil if unique
|
76
78
|
each do |allocation|
|
77
|
-
|
78
|
-
if
|
79
|
+
calculated_ids = allocation.process! amount, offset, (unique ? unique_ids : nil)
|
80
|
+
if calculated_ids.empty?
|
79
81
|
offset = offset - allocation.count unless offset.zero?
|
80
82
|
else
|
81
|
-
amount = amount -
|
83
|
+
amount = amount - calculated_ids.size # we need less results from the following allocation
|
82
84
|
offset = 0 # we have already passed the offset
|
83
85
|
end
|
84
86
|
if terminate_early && amount <= 0
|
85
87
|
break if terminate_early <= 0
|
86
88
|
terminate_early -= 1
|
87
89
|
end
|
90
|
+
unique_ids ? (unique_ids += calculated_ids) : (unique_ids = calculated_ids) if unique
|
88
91
|
end
|
89
92
|
end
|
90
93
|
|
data/lib/picky/results.rb
CHANGED
@@ -24,9 +24,9 @@ module Picky
|
|
24
24
|
|
25
25
|
# Create new results and calculate the ids.
|
26
26
|
#
|
27
|
-
def self.from query, amount, offset, allocations, extra_allocations = nil
|
27
|
+
def self.from query, amount, offset, allocations, extra_allocations = nil, unique = false
|
28
28
|
results = new query, amount, offset, allocations
|
29
|
-
results.prepare! extra_allocations
|
29
|
+
results.prepare! extra_allocations, unique
|
30
30
|
results
|
31
31
|
end
|
32
32
|
|
@@ -35,8 +35,8 @@ module Picky
|
|
35
35
|
# Without this, the allocations are not processed,
|
36
36
|
# and no ids are calculated.
|
37
37
|
#
|
38
|
-
def prepare! extra_allocations = nil
|
39
|
-
allocations.process! amount, offset, extra_allocations
|
38
|
+
def prepare! extra_allocations = nil, unique = false
|
39
|
+
allocations.process! amount, offset, extra_allocations, unique
|
40
40
|
end
|
41
41
|
|
42
42
|
# Delegates to allocations.
|
data/lib/picky/search.rb
CHANGED
@@ -177,19 +177,19 @@ module Picky
|
|
177
177
|
#
|
178
178
|
# Note: The Rack adapter calls this method after unravelling the HTTP request.
|
179
179
|
#
|
180
|
-
def search text, ids = 20, offset = 0
|
181
|
-
search_with tokenized(text), ids.to_i, offset.to_i, text
|
180
|
+
def search text, ids = 20, offset = 0, options = {}
|
181
|
+
search_with tokenized(text), ids.to_i, offset.to_i, text, options[:unique]
|
182
182
|
end
|
183
183
|
|
184
184
|
# Runs the actual search using Query::Tokens.
|
185
185
|
#
|
186
186
|
# Note: Internal method, use #search to search.
|
187
187
|
#
|
188
|
-
def search_with tokens, ids = 20, offset = 0, original_text = nil
|
188
|
+
def search_with tokens, ids = 20, offset = 0, original_text = nil, unique = false
|
189
189
|
results = nil
|
190
190
|
|
191
191
|
duration = timed do
|
192
|
-
results = execute tokens, ids, offset, original_text
|
192
|
+
results = execute tokens, ids, offset, original_text, unique
|
193
193
|
end
|
194
194
|
results.duration = duration.round 6
|
195
195
|
|
@@ -200,8 +200,13 @@ module Picky
|
|
200
200
|
#
|
201
201
|
# Note: Internal method, use #search to search.
|
202
202
|
#
|
203
|
-
def execute tokens, ids, offset, original_text = nil
|
204
|
-
Results.from original_text,
|
203
|
+
def execute tokens, ids, offset, original_text = nil, unique = false
|
204
|
+
Results.from original_text,
|
205
|
+
ids,
|
206
|
+
offset,
|
207
|
+
sorted_allocations(tokens, @max_allocations),
|
208
|
+
@extra_allocations,
|
209
|
+
unique
|
205
210
|
end
|
206
211
|
|
207
212
|
# Delegates the tokenizing to the query tokenizer.
|
data/lib/picky.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Picky::Backends::Memory::JSON do
|
6
|
+
|
7
|
+
let(:backend) { described_class.new '/tmp/picky_test_cache' }
|
8
|
+
|
9
|
+
describe "dump_json" do
|
10
|
+
it "works with ascii characters" do
|
11
|
+
backend.dump_json key: 'abc'
|
12
|
+
end
|
13
|
+
it "works with cyrillic characters" do
|
14
|
+
backend.dump_json key: 'й'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'unique option on a search' do
|
6
|
+
|
7
|
+
it 'works' do
|
8
|
+
index = Picky::Index.new :non_unique do
|
9
|
+
category :text1
|
10
|
+
category :text2
|
11
|
+
category :text3
|
12
|
+
category :text4
|
13
|
+
end
|
14
|
+
|
15
|
+
thing = Struct.new :id, :text1, :text2, :text3, :text4
|
16
|
+
index.add thing.new(1, 'hello world', 'hello world', 'hello world', 'hello world')
|
17
|
+
index.add thing.new(2, 'hello world', 'hello world', 'hello world', 'hello world')
|
18
|
+
index.add thing.new(3, 'hello world', 'hello world', 'hello world', 'hello world')
|
19
|
+
index.add thing.new(4, 'hello world', 'hello world', 'hello world', 'hello world')
|
20
|
+
index.add thing.new(5, 'hello world', 'hello world', 'hello world', 'hello world')
|
21
|
+
index.add thing.new(6, 'hello world', 'hello world', 'hello world', 'hello world')
|
22
|
+
|
23
|
+
things = Picky::Search.new index
|
24
|
+
things.search('hello', 100, 0).ids.should == [
|
25
|
+
6, 5, 4, 3, 2, 1,
|
26
|
+
6, 5, 4, 3, 2, 1,
|
27
|
+
6, 5, 4, 3, 2, 1,
|
28
|
+
6, 5, 4, 3, 2, 1
|
29
|
+
]
|
30
|
+
things.search('hello', 100, 0, unique: true).ids.should == [
|
31
|
+
6, 5, 4, 3, 2, 1
|
32
|
+
]
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'works' do
|
36
|
+
index = Picky::Index.new :non_unique do
|
37
|
+
category :text1
|
38
|
+
category :text2
|
39
|
+
end
|
40
|
+
|
41
|
+
thing = Struct.new :id, :text1, :text2
|
42
|
+
index.add thing.new(1, 'one', 'two one')
|
43
|
+
index.add thing.new(2, 'two', 'three')
|
44
|
+
index.add thing.new(3, 'three', 'one')
|
45
|
+
|
46
|
+
things = Picky::Search.new index
|
47
|
+
things.search('one', 20, 0).ids.should == [3,1,1]
|
48
|
+
things.search('one', 20, 0).allocations.to_s.should == '[[:non_unique, 0.693, 2, [[:text2, "one", "one"]], [3, 1]], [:non_unique, 0.0, 1, [[:text1, "one", "one"]], [1]]]'
|
49
|
+
|
50
|
+
things.search('one', 20, 0, unique: true).ids.should == [3,1]
|
51
|
+
things.search('one', 20, 0, unique: true).allocations.to_s.should == '[[:non_unique, 0.693, 2, [[:text2, "one", "one"]], [3, 1]]]'
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Picky do
|
4
|
+
|
5
|
+
it 'sets the right internal encoding' do
|
6
|
+
Encoding.default_external.should == Encoding::UTF_8
|
7
|
+
end
|
8
|
+
# TODO Set default external encoding.
|
9
|
+
#
|
10
|
+
# it 'sets the right external encoding' do
|
11
|
+
# Encoding.default_internal.should == Encoding::UTF_8
|
12
|
+
# end
|
13
|
+
|
14
|
+
end
|
@@ -111,6 +111,32 @@ describe Picky::Query::Allocation do
|
|
111
111
|
@allocation.process!(20, 10).should == []
|
112
112
|
end
|
113
113
|
end
|
114
|
+
context 'with ids & illegal ids' do
|
115
|
+
before(:each) do
|
116
|
+
@allocation.stub! :calculate_ids => [1,2,3,4,5,6,7,8,9,10]
|
117
|
+
end
|
118
|
+
it 'should process right' do
|
119
|
+
@allocation.process!(0, 0, [1,3,7]).should == []
|
120
|
+
end
|
121
|
+
it 'should process right' do
|
122
|
+
@allocation.process!(0, 10, [1,3,7]).should == []
|
123
|
+
end
|
124
|
+
it 'should process right' do
|
125
|
+
@allocation.process!(5, 0, [1,3,7]).should == [2,4,5,6,8]
|
126
|
+
end
|
127
|
+
it 'should process right' do
|
128
|
+
@allocation.process!(5, 5, [1,3,7]).should == [9,10]
|
129
|
+
end
|
130
|
+
it 'should process right' do
|
131
|
+
@allocation.process!(20, 0, [1,3,7]).should == [2,4,5,6,8,9,10]
|
132
|
+
end
|
133
|
+
it 'should process right' do
|
134
|
+
@allocation.process!(20, 5, [1,3,7]).should == [9,10]
|
135
|
+
end
|
136
|
+
it 'should process right' do
|
137
|
+
@allocation.process!(20, 10, [1,3,7]).should == []
|
138
|
+
end
|
139
|
+
end
|
114
140
|
end
|
115
141
|
|
116
142
|
describe 'to_result' do
|
@@ -93,12 +93,19 @@ describe Picky::Query::Allocations do
|
|
93
93
|
@offset = 1
|
94
94
|
end
|
95
95
|
it 'should call the process! method right' do
|
96
|
-
@allocation1.should_receive(:process!).once.with(5,1).and_return [2, 3, 4]
|
97
|
-
@allocation2.should_receive(:process!).once.with(2,0).and_return [5, 6]
|
96
|
+
@allocation1.should_receive(:process!).once.with(5,1,nil).and_return [2, 3, 4]
|
97
|
+
@allocation2.should_receive(:process!).once.with(2,0,nil).and_return [5, 6]
|
98
98
|
@allocation3.should_receive(:process!).never
|
99
99
|
|
100
100
|
@allocations.process! @amount, @offset, 0
|
101
101
|
end
|
102
|
+
it 'should call the process! method right including unique' do
|
103
|
+
@allocation1.should_receive(:process!).once.with(5,1,nil).and_return [2, 3, 4]
|
104
|
+
@allocation2.should_receive(:process!).once.with(2,0,[2,3,4]).and_return [5, 6]
|
105
|
+
@allocation3.should_receive(:process!).never
|
106
|
+
|
107
|
+
@allocations.process! @amount, @offset, 0, true
|
108
|
+
end
|
102
109
|
end
|
103
110
|
context 'larger amount' do
|
104
111
|
before(:each) do
|
@@ -106,7 +113,7 @@ describe Picky::Query::Allocations do
|
|
106
113
|
@offset = 0
|
107
114
|
end
|
108
115
|
it 'should call the process! method right' do
|
109
|
-
@allocation1.should_receive(:process!).once.with(1,0).and_return [1]
|
116
|
+
@allocation1.should_receive(:process!).once.with(1,0,nil).and_return [1]
|
110
117
|
@allocation2.should_receive(:process!).never
|
111
118
|
@allocation3.should_receive(:process!).never
|
112
119
|
|
@@ -119,9 +126,9 @@ describe Picky::Query::Allocations do
|
|
119
126
|
@offset = 1
|
120
127
|
end
|
121
128
|
it 'should call the process! method right' do
|
122
|
-
@allocation1.should_receive(:process!).once.with(5,1).and_return [2, 3, 4]
|
123
|
-
@allocation2.should_receive(:process!).once.with(2,0).and_return [5, 6]
|
124
|
-
@allocation3.should_receive(:process!).once.with(0,0).and_return []
|
129
|
+
@allocation1.should_receive(:process!).once.with(5,1,nil).and_return [2, 3, 4]
|
130
|
+
@allocation2.should_receive(:process!).once.with(2,0,nil).and_return [5, 6]
|
131
|
+
@allocation3.should_receive(:process!).once.with(0,0,nil).and_return []
|
125
132
|
|
126
133
|
@allocations.process! @amount, @offset, 1
|
127
134
|
end
|
@@ -132,8 +139,8 @@ describe Picky::Query::Allocations do
|
|
132
139
|
@offset = 0
|
133
140
|
end
|
134
141
|
it 'should call the process! method right' do
|
135
|
-
@allocation1.should_receive(:process!).once.with(1,0).and_return [1]
|
136
|
-
@allocation2.should_receive(:process!).once.with(0,0).and_return []
|
142
|
+
@allocation1.should_receive(:process!).once.with(1,0,nil).and_return [1]
|
143
|
+
@allocation2.should_receive(:process!).once.with(0,0,nil).and_return []
|
137
144
|
@allocation3.should_receive(:process!).never
|
138
145
|
|
139
146
|
@allocations.process! @amount, @offset, 1
|
@@ -145,7 +152,7 @@ describe Picky::Query::Allocations do
|
|
145
152
|
@offset = 0
|
146
153
|
end
|
147
154
|
it 'should call the process! method right' do
|
148
|
-
@allocation1.should_receive(:process!).once.with(4,0).and_return [1, 2, 3, 4]
|
155
|
+
@allocation1.should_receive(:process!).once.with(4,0,nil).and_return [1, 2, 3, 4]
|
149
156
|
@allocation2.should_receive(:process!).never
|
150
157
|
@allocation3.should_receive(:process!).never
|
151
158
|
|
@@ -158,8 +165,8 @@ describe Picky::Query::Allocations do
|
|
158
165
|
@offset = 0
|
159
166
|
end
|
160
167
|
it 'should call the process! method right' do
|
161
|
-
@allocation1.should_receive(:process!).once.with(4,0).and_return [1, 2, 3, 4]
|
162
|
-
@allocation2.should_receive(:process!).once.with(0,0).and_return []
|
168
|
+
@allocation1.should_receive(:process!).once.with(4,0,nil).and_return [1, 2, 3, 4]
|
169
|
+
@allocation2.should_receive(:process!).once.with(0,0,nil).and_return []
|
163
170
|
@allocation3.should_receive(:process!).never
|
164
171
|
|
165
172
|
@allocations.process! @amount, @offset, 1
|
@@ -171,8 +178,8 @@ describe Picky::Query::Allocations do
|
|
171
178
|
@offset = 0
|
172
179
|
end
|
173
180
|
it 'should call the process! method right' do
|
174
|
-
@allocation1.should_receive(:process!).once.with(5,0).and_return [1, 2, 3, 4]
|
175
|
-
@allocation2.should_receive(:process!).once.with(1,0).and_return [5]
|
181
|
+
@allocation1.should_receive(:process!).once.with(5,0,nil).and_return [1, 2, 3, 4]
|
182
|
+
@allocation2.should_receive(:process!).once.with(1,0,nil).and_return [5]
|
176
183
|
@allocation3.should_receive(:process!).never
|
177
184
|
|
178
185
|
@allocations.process! @amount, @offset, 0
|
@@ -184,9 +191,9 @@ describe Picky::Query::Allocations do
|
|
184
191
|
@offset = 0
|
185
192
|
end
|
186
193
|
it 'should call the process! method right' do
|
187
|
-
@allocation1.should_receive(:process!).once.with(5,0).and_return [1, 2, 3, 4]
|
188
|
-
@allocation2.should_receive(:process!).once.with(1,0).and_return [5]
|
189
|
-
@allocation3.should_receive(:process!).once.with(0,0).and_return []
|
194
|
+
@allocation1.should_receive(:process!).once.with(5,0,nil).and_return [1, 2, 3, 4]
|
195
|
+
@allocation2.should_receive(:process!).once.with(1,0,nil).and_return [5]
|
196
|
+
@allocation3.should_receive(:process!).once.with(0,0,nil).and_return []
|
190
197
|
|
191
198
|
@allocations.process! @amount, @offset, 1
|
192
199
|
end
|
@@ -197,9 +204,9 @@ describe Picky::Query::Allocations do
|
|
197
204
|
@offset = 0
|
198
205
|
end
|
199
206
|
it 'should call the process! method right' do
|
200
|
-
@allocation1.should_receive(:process!).once.with(8,0).and_return [1, 2, 3, 4]
|
201
|
-
@allocation2.should_receive(:process!).once.with(4,0).and_return [5, 6, 7]
|
202
|
-
@allocation3.should_receive(:process!).once.with(1,0).and_return [8]
|
207
|
+
@allocation1.should_receive(:process!).once.with(8,0,nil).and_return [1, 2, 3, 4]
|
208
|
+
@allocation2.should_receive(:process!).once.with(4,0,nil).and_return [5, 6, 7]
|
209
|
+
@allocation3.should_receive(:process!).once.with(1,0,nil).and_return [8]
|
203
210
|
|
204
211
|
@allocations.process! @amount, @offset, 1
|
205
212
|
end
|
@@ -211,9 +218,9 @@ describe Picky::Query::Allocations do
|
|
211
218
|
@offset = 2
|
212
219
|
end
|
213
220
|
it 'should call the process! method right' do
|
214
|
-
@allocation1.should_receive(:process!).once.with(6,2).and_return [3,4]
|
215
|
-
@allocation2.should_receive(:process!).once.with(4,0).and_return [5,6,7]
|
216
|
-
@allocation3.should_receive(:process!).once.with(1,0).and_return [8]
|
221
|
+
@allocation1.should_receive(:process!).once.with(6,2,nil).and_return [3,4]
|
222
|
+
@allocation2.should_receive(:process!).once.with(4,0,nil).and_return [5,6,7]
|
223
|
+
@allocation3.should_receive(:process!).once.with(1,0,nil).and_return [8]
|
217
224
|
|
218
225
|
@allocations.process! @amount, @offset
|
219
226
|
end
|
@@ -224,9 +231,9 @@ describe Picky::Query::Allocations do
|
|
224
231
|
@offset = 8
|
225
232
|
end
|
226
233
|
it 'should call the process! method right' do
|
227
|
-
@allocation1.should_receive(:process!).once.with(10,8).and_return []
|
228
|
-
@allocation2.should_receive(:process!).once.with(10,4).and_return []
|
229
|
-
@allocation3.should_receive(:process!).once.with(10,1).and_return [9]
|
234
|
+
@allocation1.should_receive(:process!).once.with(10,8,nil).and_return []
|
235
|
+
@allocation2.should_receive(:process!).once.with(10,4,nil).and_return []
|
236
|
+
@allocation3.should_receive(:process!).once.with(10,1,nil).and_return [9]
|
230
237
|
|
231
238
|
@allocations.process! @amount, @offset
|
232
239
|
end
|
@@ -236,9 +243,9 @@ describe Picky::Query::Allocations do
|
|
236
243
|
@amount = 0
|
237
244
|
end
|
238
245
|
it 'should return an empty array always' do
|
239
|
-
@allocation1.should_receive(:process!).once.with(0,0).and_return []
|
240
|
-
@allocation2.should_receive(:process!).once.with(0,0).and_return []
|
241
|
-
@allocation3.should_receive(:process!).once.with(0,0).and_return []
|
246
|
+
@allocation1.should_receive(:process!).once.with(0,0,nil).and_return []
|
247
|
+
@allocation2.should_receive(:process!).once.with(0,0,nil).and_return []
|
248
|
+
@allocation3.should_receive(:process!).once.with(0,0,nil).and_return []
|
242
249
|
|
243
250
|
@allocations.process! @amount
|
244
251
|
end
|
@@ -252,9 +259,9 @@ describe Picky::Query::Allocations do
|
|
252
259
|
@offset = 0
|
253
260
|
end
|
254
261
|
it 'should return certain ids' do
|
255
|
-
@allocation1.should_receive(:process!).once.with(3,0).and_return [1,2,3]
|
256
|
-
@allocation2.should_receive(:process!).once.with(0,0).and_return []
|
257
|
-
@allocation3.should_receive(:process!).once.with(0,0).and_return []
|
262
|
+
@allocation1.should_receive(:process!).once.with(3,0,nil).and_return [1,2,3]
|
263
|
+
@allocation2.should_receive(:process!).once.with(0,0,nil).and_return []
|
264
|
+
@allocation3.should_receive(:process!).once.with(0,0,nil).and_return []
|
258
265
|
|
259
266
|
@allocations.process! @amount, @offset
|
260
267
|
end
|
@@ -264,9 +271,9 @@ describe Picky::Query::Allocations do
|
|
264
271
|
@offset = 3
|
265
272
|
end
|
266
273
|
it 'should return certain ids' do
|
267
|
-
@allocation1.should_receive(:process!).once.with(3,3).and_return [4]
|
268
|
-
@allocation2.should_receive(:process!).once.with(2,0).and_return [5,6]
|
269
|
-
@allocation3.should_receive(:process!).once.with(0,0).and_return []
|
274
|
+
@allocation1.should_receive(:process!).once.with(3,3,nil).and_return [4]
|
275
|
+
@allocation2.should_receive(:process!).once.with(2,0,nil).and_return [5,6]
|
276
|
+
@allocation3.should_receive(:process!).once.with(0,0,nil).and_return []
|
270
277
|
|
271
278
|
@allocations.process! @amount, @offset
|
272
279
|
end
|
data/spec/lib/search_spec.rb
CHANGED
@@ -91,17 +91,24 @@ describe Picky::Search do
|
|
91
91
|
it "delegates to search_with correctly" do
|
92
92
|
@search.stub! :tokenized => :tokens
|
93
93
|
|
94
|
-
@search.should_receive(:search_with).once.with :tokens, 20, 10, :text
|
94
|
+
@search.should_receive(:search_with).once.with :tokens, 20, 10, :text, nil
|
95
95
|
|
96
96
|
@search.search :text, 20, 10
|
97
97
|
end
|
98
98
|
it "delegates to search_with correctly" do
|
99
99
|
@search.stub! :tokenized => :tokens
|
100
100
|
|
101
|
-
@search.should_receive(:search_with).once.with :tokens, 20, 0, :text
|
101
|
+
@search.should_receive(:search_with).once.with :tokens, 20, 0, :text, nil
|
102
102
|
|
103
103
|
@search.search :text, 20, 0
|
104
104
|
end
|
105
|
+
it "delegates to search_with correctly" do
|
106
|
+
@search.stub! :tokenized => :tokens
|
107
|
+
|
108
|
+
@search.should_receive(:search_with).once.with :tokens, 20, 0, :text, true
|
109
|
+
|
110
|
+
@search.search :text, 20, 0, unique: true
|
111
|
+
end
|
105
112
|
it "uses the tokenizer" do
|
106
113
|
@search.stub! :search_with
|
107
114
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70172962714740 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,21 +21,21 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70172962714740
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: picky-client
|
27
|
-
requirement: &
|
27
|
+
requirement: &70172962714020 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 4.
|
32
|
+
version: 4.4.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70172962714020
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: text
|
38
|
-
requirement: &
|
38
|
+
requirement: &70172962713380 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70172962713380
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yajl-ruby
|
49
|
-
requirement: &
|
49
|
+
requirement: &70172962712340 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70172962712340
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: activesupport
|
60
|
-
requirement: &
|
60
|
+
requirement: &70172962711160 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '3.0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70172962711160
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: procrastinate
|
71
|
-
requirement: &
|
71
|
+
requirement: &70172962709300 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0.4'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70172962709300
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rack_fast_escape
|
82
|
-
requirement: &
|
82
|
+
requirement: &70172962723720 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70172962723720
|
91
91
|
description: Fast Ruby semantic text search engine with comfortable single field interface.
|
92
92
|
email: florian.hanke+picky@gmail.com
|
93
93
|
executables:
|
@@ -244,6 +244,7 @@ files:
|
|
244
244
|
- spec/ext/performant_spec.rb
|
245
245
|
- spec/functional/backends/file_spec.rb
|
246
246
|
- spec/functional/backends/memory_bundle_realtime_spec.rb
|
247
|
+
- spec/functional/backends/memory_json_utf8_spec.rb
|
247
248
|
- spec/functional/backends/memory_spec.rb
|
248
249
|
- spec/functional/backends/redis_bundle_realtime_spec.rb
|
249
250
|
- spec/functional/backends/redis_spec.rb
|
@@ -261,6 +262,7 @@ files:
|
|
261
262
|
- spec/functional/speed_spec.rb
|
262
263
|
- spec/functional/terminate_early_spec.rb
|
263
264
|
- spec/functional/tokenizer_spec.rb
|
265
|
+
- spec/functional/unique_ids_search_spec.rb
|
264
266
|
- spec/integration/sinatra_index_actions_spec.rb
|
265
267
|
- spec/lib/analytics_spec.rb
|
266
268
|
- spec/lib/analyzer_spec.rb
|
@@ -343,6 +345,7 @@ files:
|
|
343
345
|
- spec/lib/loggers/concise_spec.rb
|
344
346
|
- spec/lib/loggers/silent_spec.rb
|
345
347
|
- spec/lib/loggers/verbose_spec.rb
|
348
|
+
- spec/lib/picky_spec.rb
|
346
349
|
- spec/lib/query/allocation_spec.rb
|
347
350
|
- spec/lib/query/allocations_spec.rb
|
348
351
|
- spec/lib/query/boosts_spec.rb
|
@@ -395,6 +398,7 @@ test_files:
|
|
395
398
|
- spec/ext/performant_spec.rb
|
396
399
|
- spec/functional/backends/file_spec.rb
|
397
400
|
- spec/functional/backends/memory_bundle_realtime_spec.rb
|
401
|
+
- spec/functional/backends/memory_json_utf8_spec.rb
|
398
402
|
- spec/functional/backends/memory_spec.rb
|
399
403
|
- spec/functional/backends/redis_bundle_realtime_spec.rb
|
400
404
|
- spec/functional/backends/redis_spec.rb
|
@@ -412,6 +416,7 @@ test_files:
|
|
412
416
|
- spec/functional/speed_spec.rb
|
413
417
|
- spec/functional/terminate_early_spec.rb
|
414
418
|
- spec/functional/tokenizer_spec.rb
|
419
|
+
- spec/functional/unique_ids_search_spec.rb
|
415
420
|
- spec/integration/sinatra_index_actions_spec.rb
|
416
421
|
- spec/lib/analytics_spec.rb
|
417
422
|
- spec/lib/analyzer_spec.rb
|
@@ -494,6 +499,7 @@ test_files:
|
|
494
499
|
- spec/lib/loggers/concise_spec.rb
|
495
500
|
- spec/lib/loggers/silent_spec.rb
|
496
501
|
- spec/lib/loggers/verbose_spec.rb
|
502
|
+
- spec/lib/picky_spec.rb
|
497
503
|
- spec/lib/query/allocation_spec.rb
|
498
504
|
- spec/lib/query/allocations_spec.rb
|
499
505
|
- spec/lib/query/boosts_spec.rb
|