picky 3.1.9 → 3.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/picky/backends/file/basic.rb +6 -0
- data/lib/picky/backends/memory/json.rb +6 -0
- data/lib/picky/backends/memory/marshal.rb +6 -0
- data/lib/picky/backends/memory/text.rb +6 -0
- data/lib/picky/backends/redis/basic.rb +6 -0
- data/lib/picky/bundle.rb +5 -1
- data/lib/picky/categories_realtime.rb +27 -0
- data/lib/picky/category.rb +7 -4
- data/lib/picky/category_realtime.rb +32 -0
- data/lib/picky/generators/partial/infix.rb +21 -17
- data/lib/picky/generators/partial/none.rb +6 -0
- data/lib/picky/generators/partial/substring.rb +21 -17
- data/lib/picky/index_realtime.rb +16 -0
- data/lib/picky/indexed/bundle.rb +13 -0
- data/lib/picky/indexed/bundle_realtime.rb +55 -0
- data/lib/picky/indexing/bundle.rb +1 -6
- data/lib/picky/loader.rb +4 -0
- data/spec/lib/bundle_spec.rb +8 -2
- data/spec/lib/indexed/bundle_realtime_spec.rb +105 -0
- data/spec/lib/indexed/{memory_spec.rb → bundle_spec.rb} +4 -2
- data/spec/specific/realtime_spec.rb +131 -0
- metadata +50 -47
@@ -30,6 +30,12 @@ module Picky
|
|
30
30
|
@mapping_file = Memory::JSON.new "#{cache_path}.file_mapping.#{extension}"
|
31
31
|
end
|
32
32
|
|
33
|
+
# The initial content before loading.
|
34
|
+
#
|
35
|
+
def default
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
|
33
39
|
# The default extension for index files is "index".
|
34
40
|
#
|
35
41
|
def extension
|
data/lib/picky/bundle.rb
CHANGED
@@ -36,14 +36,18 @@ module Picky
|
|
36
36
|
:backend_similarity,
|
37
37
|
:backend_configuration,
|
38
38
|
|
39
|
+
:weights_strategy,
|
40
|
+
:partial_strategy,
|
39
41
|
:similarity_strategy
|
40
42
|
|
41
43
|
delegate :[], :[]=, :to => :configuration
|
42
44
|
delegate :index_directory, :to => :category
|
43
45
|
|
44
|
-
def initialize name, category, backend, similarity_strategy, options = {}
|
46
|
+
def initialize name, category, backend, weights_strategy, partial_strategy, similarity_strategy, options = {}
|
45
47
|
@name = name
|
46
48
|
@category = category
|
49
|
+
@weights_strategy = weights_strategy
|
50
|
+
@partial_strategy = partial_strategy
|
47
51
|
@similarity_strategy = similarity_strategy
|
48
52
|
|
49
53
|
# Extract specific indexes from backend.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Picky
|
2
|
+
|
3
|
+
class Categories
|
4
|
+
|
5
|
+
each_delegate :remove,
|
6
|
+
:to => :categories
|
7
|
+
|
8
|
+
# TODO Rewrite indexing/tokenizer/caching etc.
|
9
|
+
#
|
10
|
+
def add object
|
11
|
+
id = object.id
|
12
|
+
categories.each do |category|
|
13
|
+
tokens, _ = category.tokenizer.tokenize object.send(category.from).to_s
|
14
|
+
category.add id, tokens
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# TODO
|
19
|
+
#
|
20
|
+
def replace object
|
21
|
+
remove object.id
|
22
|
+
add object
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/lib/picky/category.rb
CHANGED
@@ -35,16 +35,19 @@ module Picky
|
|
35
35
|
partial = options[:partial] || Generators::Partial::Default
|
36
36
|
similarity = options[:similarity] || Generators::Similarity::Default
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
no_partial = Generators::Partial::None.new
|
39
|
+
no_similarity = Generators::Similarity::None.new
|
40
|
+
|
41
|
+
@indexing_exact = Indexing::Bundle.new :exact, self, index.backend, weights, no_partial, similarity, options
|
42
|
+
@indexing_partial = Indexing::Bundle.new :partial, self, index.backend, weights, partial, no_similarity, options
|
40
43
|
|
41
44
|
# Indexed.
|
42
45
|
#
|
43
|
-
@indexed_exact = Indexed::Bundle.new :exact, self, index.backend, similarity
|
46
|
+
@indexed_exact = Indexed::Bundle.new :exact, self, index.backend, weights, no_partial, similarity
|
44
47
|
if partial.use_exact_for_partial?
|
45
48
|
@indexed_partial = @indexed_exact
|
46
49
|
else
|
47
|
-
@indexed_partial = Indexed::Bundle.new :partial, self, index.backend,
|
50
|
+
@indexed_partial = Indexed::Bundle.new :partial, self, index.backend, weights, partial, no_similarity
|
48
51
|
end
|
49
52
|
|
50
53
|
# @exact = exact_lambda.call(@exact, @partial) if exact_lambda = options[:exact_lambda]
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Picky
|
2
|
+
|
3
|
+
# TODO
|
4
|
+
#
|
5
|
+
class Category
|
6
|
+
|
7
|
+
# TODO
|
8
|
+
#
|
9
|
+
def remove id
|
10
|
+
indexed_exact.remove id
|
11
|
+
indexed_partial.remove id
|
12
|
+
end
|
13
|
+
|
14
|
+
# TODO
|
15
|
+
#
|
16
|
+
def add id, tokens
|
17
|
+
tokens.each do |text|
|
18
|
+
next unless text
|
19
|
+
text = text.to_sym
|
20
|
+
indexed_exact.add id, text
|
21
|
+
|
22
|
+
# TODO Beautify.
|
23
|
+
#
|
24
|
+
indexed_partial.partial_strategy.each_partial text do |partial_text|
|
25
|
+
indexed_partial.add id, partial_text
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -35,6 +35,12 @@ module Picky
|
|
35
35
|
@max = options[:max] || -1
|
36
36
|
end
|
37
37
|
|
38
|
+
# Yields each generated partial.
|
39
|
+
#
|
40
|
+
def each_partial token, &block
|
41
|
+
token.each_intoken min, max, &block
|
42
|
+
end
|
43
|
+
|
38
44
|
# Generates a partial index from the given inverted index.
|
39
45
|
#
|
40
46
|
def generate_from inverted
|
@@ -64,25 +70,23 @@ module Picky
|
|
64
70
|
result
|
65
71
|
end
|
66
72
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
else
|
82
|
-
result[intoken] = inverted[token].dup
|
83
|
-
end
|
73
|
+
# To each shortened token of :test
|
74
|
+
# :test, :tes, :te, :t
|
75
|
+
# add all ids of :test
|
76
|
+
#
|
77
|
+
# "token" here means just text.
|
78
|
+
#
|
79
|
+
# THINK Could be improved by appending the aforegoing ids?
|
80
|
+
#
|
81
|
+
def generate_for token, inverted, result
|
82
|
+
each_partial token do |intoken|
|
83
|
+
if result[intoken]
|
84
|
+
result[intoken] += inverted[token] # unique
|
85
|
+
else
|
86
|
+
result[intoken] = inverted[token].dup
|
84
87
|
end
|
85
88
|
end
|
89
|
+
end
|
86
90
|
|
87
91
|
end
|
88
92
|
|
@@ -66,6 +66,12 @@ module Picky
|
|
66
66
|
@generator.to
|
67
67
|
end
|
68
68
|
|
69
|
+
# Yields each generated partial.
|
70
|
+
#
|
71
|
+
def each_partial token, &block
|
72
|
+
@generator.each_subtoken token, &block
|
73
|
+
end
|
74
|
+
|
69
75
|
# Generates a partial index from the given inverted index.
|
70
76
|
#
|
71
77
|
def generate_from inverted
|
@@ -95,25 +101,23 @@ module Picky
|
|
95
101
|
result
|
96
102
|
end
|
97
103
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
else
|
113
|
-
result[subtoken] = inverted[token].dup
|
114
|
-
end
|
104
|
+
# To each shortened token of :test
|
105
|
+
# :test, :tes, :te, :t
|
106
|
+
# add all ids of :test
|
107
|
+
#
|
108
|
+
# "token" here means just text.
|
109
|
+
#
|
110
|
+
# THINK Could be improved by appending the aforegoing ids?
|
111
|
+
#
|
112
|
+
def generate_for token, inverted, result
|
113
|
+
each_partial token do |subtoken|
|
114
|
+
if result[subtoken]
|
115
|
+
result[subtoken] += inverted[token] # unique
|
116
|
+
else
|
117
|
+
result[subtoken] = inverted[token].dup
|
115
118
|
end
|
116
119
|
end
|
120
|
+
end
|
117
121
|
|
118
122
|
end
|
119
123
|
|
data/lib/picky/indexed/bundle.rb
CHANGED
@@ -18,6 +18,19 @@ module Picky
|
|
18
18
|
#
|
19
19
|
class Bundle < Picky::Bundle
|
20
20
|
|
21
|
+
attr_reader :realtime_mapping
|
22
|
+
|
23
|
+
def initialize name, category, backend, weights_strategy, partial_strategy, similarity_strategy, options = {}
|
24
|
+
super name, category, backend, weights_strategy, partial_strategy, similarity_strategy, options
|
25
|
+
|
26
|
+
@inverted = @backend_inverted.default
|
27
|
+
@weights = @backend_weights.default
|
28
|
+
@similarity = @backend_similarity.default
|
29
|
+
@configuration = @backend_configuration.default
|
30
|
+
|
31
|
+
@realtime_mapping = {} # id -> ary of syms. TODO Always instantiate?
|
32
|
+
end
|
33
|
+
|
21
34
|
# Get the ids for the given symbol.
|
22
35
|
#
|
23
36
|
# Returns a (potentially empty) array of ids.
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Picky
|
2
|
+
|
3
|
+
module Indexed # :nodoc:all
|
4
|
+
|
5
|
+
class Bundle < Picky::Bundle
|
6
|
+
|
7
|
+
# Removes the given id from the indexes.
|
8
|
+
#
|
9
|
+
def remove id
|
10
|
+
# Is it anywhere?
|
11
|
+
#
|
12
|
+
syms = @realtime_mapping[id]
|
13
|
+
return unless syms
|
14
|
+
|
15
|
+
syms.each do |sym|
|
16
|
+
ids = @inverted[sym]
|
17
|
+
ids.delete id
|
18
|
+
|
19
|
+
if ids.empty?
|
20
|
+
@inverted.delete sym
|
21
|
+
@weights.delete sym
|
22
|
+
else
|
23
|
+
@weights[sym] = self.weights_strategy.weight_for ids.size
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
@realtime_mapping.delete id
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns a reference to the array where the id has been added.
|
31
|
+
#
|
32
|
+
def add id, sym
|
33
|
+
ary = @inverted[sym]
|
34
|
+
|
35
|
+
syms = @realtime_mapping[id]
|
36
|
+
syms = (@realtime_mapping[id] = []) unless syms # TODO Nicefy.
|
37
|
+
|
38
|
+
ids = if syms.include? sym
|
39
|
+
ids = @inverted[sym]
|
40
|
+
ids.delete id # Move id
|
41
|
+
ids.unshift id # to front
|
42
|
+
else
|
43
|
+
syms << sym
|
44
|
+
inverted = @inverted[sym] ||= []
|
45
|
+
inverted.unshift id
|
46
|
+
end
|
47
|
+
|
48
|
+
@weights[sym] = self.weights_strategy.weight_for ids.size
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -33,18 +33,13 @@ module Picky
|
|
33
33
|
attr_reader :backend,
|
34
34
|
:prepared
|
35
35
|
|
36
|
-
attr_accessor :partial_strategy,
|
37
|
-
:weights_strategy
|
38
|
-
|
39
36
|
# When indexing, clear only clears the inverted index.
|
40
37
|
#
|
41
38
|
delegate :clear, :to => :inverted
|
42
39
|
|
43
40
|
def initialize name, category, backend, weights_strategy, partial_strategy, similarity_strategy, options = {}
|
44
|
-
super name, category, backend, similarity_strategy, options
|
41
|
+
super name, category, backend, weights_strategy, partial_strategy, similarity_strategy, options
|
45
42
|
|
46
|
-
@weights_strategy = weights_strategy
|
47
|
-
@partial_strategy = partial_strategy
|
48
43
|
@key_format = options[:key_format]
|
49
44
|
@prepared = Backends::Memory::Text.new category.prepared_index_path
|
50
45
|
|
data/lib/picky/loader.rb
CHANGED
@@ -138,6 +138,7 @@ module Picky
|
|
138
138
|
load_relative 'indexing/wrappers/category/location'
|
139
139
|
|
140
140
|
load_relative 'indexed/bundle'
|
141
|
+
load_relative 'indexed/bundle_realtime'
|
141
142
|
load_relative 'indexed/wrappers/exact_first'
|
142
143
|
|
143
144
|
# Bundle Wrapper
|
@@ -211,10 +212,12 @@ module Picky
|
|
211
212
|
load_relative 'category'
|
212
213
|
load_relative 'category_indexed'
|
213
214
|
load_relative 'category_indexing'
|
215
|
+
load_relative 'category_realtime'
|
214
216
|
|
215
217
|
load_relative 'categories'
|
216
218
|
load_relative 'categories_indexed'
|
217
219
|
load_relative 'categories_indexing'
|
220
|
+
load_relative 'categories_realtime'
|
218
221
|
|
219
222
|
load_relative 'indexes'
|
220
223
|
load_relative 'indexes_indexed'
|
@@ -223,6 +226,7 @@ module Picky
|
|
223
226
|
load_relative 'index'
|
224
227
|
load_relative 'index_indexed'
|
225
228
|
load_relative 'index_indexing'
|
229
|
+
load_relative 'index_realtime'
|
226
230
|
|
227
231
|
# Results.
|
228
232
|
#
|
data/spec/lib/bundle_spec.rb
CHANGED
@@ -5,9 +5,15 @@ describe Picky::Bundle do
|
|
5
5
|
before(:each) do
|
6
6
|
@index = Picky::Index.new :some_index
|
7
7
|
@category = Picky::Category.new :some_category, @index
|
8
|
-
@similarity = Picky::Similarity::DoubleMetaphone.new 3
|
9
8
|
end
|
10
|
-
let(:bundle)
|
9
|
+
let(:bundle) do
|
10
|
+
described_class.new :some_name,
|
11
|
+
@category,
|
12
|
+
Picky::Backends::Memory.new,
|
13
|
+
Picky::Generators::Weights::Default,
|
14
|
+
Picky::Generators::Partial::Default,
|
15
|
+
Picky::Generators::Similarity::DoubleMetaphone.new(3)
|
16
|
+
end
|
11
17
|
|
12
18
|
describe 'identifier' do
|
13
19
|
it 'is correct' do
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Picky::Indexed::Bundle do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@index = Picky::Index.new :some_index
|
7
|
+
@category = Picky::Category.new :some_category, @index
|
8
|
+
|
9
|
+
@weights = Picky::Generators::Weights::Default
|
10
|
+
@partial = Picky::Generators::Partial::Default
|
11
|
+
@similarity = stub :similarity
|
12
|
+
@bundle = described_class.new :some_name, @category, Picky::Backends::Memory.new, @weights, @partial, @similarity
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'is by default empty' do
|
16
|
+
@bundle.realtime_mapping.should == {}
|
17
|
+
end
|
18
|
+
it 'is by default empty' do
|
19
|
+
@bundle.weights.should == {}
|
20
|
+
end
|
21
|
+
it 'is by default empty' do
|
22
|
+
@bundle.inverted.should == {}
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'combined' do
|
26
|
+
it 'works correctly' do
|
27
|
+
@bundle.add 1, :title
|
28
|
+
@bundle.add 2, :title
|
29
|
+
|
30
|
+
@bundle.realtime_mapping.should == { 1 => [:title], 2 => [:title] }
|
31
|
+
@bundle.inverted.should == { :title => [2,1] }
|
32
|
+
@bundle.weights.should == { :title => 0.6931471805599453 }
|
33
|
+
end
|
34
|
+
it 'works correctly' do
|
35
|
+
@bundle.add 1, :title
|
36
|
+
@bundle.add 2, :title
|
37
|
+
@bundle.remove 1
|
38
|
+
@bundle.remove 2
|
39
|
+
|
40
|
+
@bundle.realtime_mapping.should == {}
|
41
|
+
@bundle.weights.should == {}
|
42
|
+
@bundle.inverted.should == {}
|
43
|
+
end
|
44
|
+
it 'works correctly' do
|
45
|
+
@bundle.add 1, :title
|
46
|
+
@bundle.add 1, :other
|
47
|
+
@bundle.add 1, :whatever
|
48
|
+
@bundle.remove 1
|
49
|
+
|
50
|
+
@bundle.realtime_mapping.should == {}
|
51
|
+
@bundle.weights.should == {}
|
52
|
+
@bundle.inverted.should == {}
|
53
|
+
end
|
54
|
+
it 'works correctly' do
|
55
|
+
@bundle.add 1, :title
|
56
|
+
@bundle.add 2, :thing
|
57
|
+
@bundle.add 1, :other
|
58
|
+
@bundle.remove 1
|
59
|
+
|
60
|
+
@bundle.realtime_mapping.should == { 2 => [:thing] }
|
61
|
+
@bundle.weights.should == { :thing => 0.0 }
|
62
|
+
@bundle.inverted.should == { :thing => [2] }
|
63
|
+
end
|
64
|
+
it 'works correctly' do
|
65
|
+
@bundle.add 1, :title
|
66
|
+
@bundle.add 1, :title
|
67
|
+
|
68
|
+
@bundle.realtime_mapping.should == { 1 => [:title] }
|
69
|
+
@bundle.weights.should == { :title => 0.0 }
|
70
|
+
@bundle.inverted.should == { :title => [1] }
|
71
|
+
end
|
72
|
+
it 'works correctly' do
|
73
|
+
@bundle.add 1, :title
|
74
|
+
@bundle.remove 1
|
75
|
+
@bundle.remove 1
|
76
|
+
|
77
|
+
@bundle.realtime_mapping.should == {}
|
78
|
+
@bundle.weights.should == {}
|
79
|
+
@bundle.inverted.should == {}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe 'add' do
|
84
|
+
it 'works correctly' do
|
85
|
+
@bundle.add 1, :title
|
86
|
+
|
87
|
+
@bundle.realtime_mapping.should == { 1 => [:title] }
|
88
|
+
|
89
|
+
@bundle.add 2, :other
|
90
|
+
|
91
|
+
@bundle.realtime_mapping.should == { 1 => [:title], 2 => [:other] }
|
92
|
+
|
93
|
+
@bundle.add 1, :thing
|
94
|
+
|
95
|
+
@bundle.realtime_mapping.should == { 1 => [:title, :thing], 2 => [:other] }
|
96
|
+
end
|
97
|
+
it 'works correctly' do
|
98
|
+
@bundle.add 1, :title
|
99
|
+
|
100
|
+
@bundle.weights.should == { :title => 0.0 }
|
101
|
+
@bundle.inverted.should == { :title => [1] }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
@@ -6,8 +6,10 @@ describe Picky::Indexed::Bundle do
|
|
6
6
|
@index = Picky::Index.new :some_index
|
7
7
|
@category = Picky::Category.new :some_category, @index
|
8
8
|
|
9
|
+
@weights = stub :weights
|
10
|
+
@partial = stub :partial
|
9
11
|
@similarity = stub :similarity
|
10
|
-
@bundle = described_class.new :some_name, @category, Picky::Backends::Memory.new, @similarity
|
12
|
+
@bundle = described_class.new :some_name, @category, Picky::Backends::Memory.new, @weights, @partial, @similarity
|
11
13
|
end
|
12
14
|
|
13
15
|
describe 'to_s' do
|
@@ -156,7 +158,7 @@ describe Picky::Indexed::Bundle do
|
|
156
158
|
@index = Picky::Index.new :some_index
|
157
159
|
@category = Picky::Category.new :some_category, @index
|
158
160
|
|
159
|
-
@bundle = described_class.new :some_name, @category, Picky::Backends::Memory.new, :similarity
|
161
|
+
@bundle = described_class.new :some_name, @category, Picky::Backends::Memory.new, :weights, :partial, :similarity
|
160
162
|
end
|
161
163
|
it 'should initialize the index correctly' do
|
162
164
|
@bundle.backend_inverted.should be_kind_of(Picky::Backends::Memory::JSON)
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe "Realtime Indexing" do
|
6
|
+
|
7
|
+
class Book
|
8
|
+
attr_reader :id, :title, :author
|
9
|
+
def initialize id, title, author
|
10
|
+
@id, @title, @author = id, title, author
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:index) { Picky::Index.new(:test) { source []; category :title; category :author } }
|
15
|
+
let(:books) { Picky::Search.new index }
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
index.add Book.new(1, "Title", "Author")
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'with partial' do
|
22
|
+
it 'finds the first entry' do
|
23
|
+
books.search('Titl').ids.should == [1]
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'allows removing something' do
|
27
|
+
index.remove 1
|
28
|
+
end
|
29
|
+
it 'is not findable anymore after removing' do
|
30
|
+
books.search('Titl').ids.should == [1]
|
31
|
+
|
32
|
+
index.remove 1
|
33
|
+
|
34
|
+
books.search('Titl').ids.should == []
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'allows adding something' do
|
38
|
+
index.add Book.new(2, "Title2", "Author2")
|
39
|
+
end
|
40
|
+
it 'is findable after adding' do
|
41
|
+
books.search('Titl').ids.should == [1]
|
42
|
+
|
43
|
+
index.add Book.new(2, "Title New", "Author New")
|
44
|
+
|
45
|
+
books.search('Titl').ids.should == [2,1]
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'allows replacing something' do
|
49
|
+
index.replace Book.new(1, "Title New", "Author New")
|
50
|
+
end
|
51
|
+
it 'is findable after replacing' do
|
52
|
+
books.search('Ne').ids.should == []
|
53
|
+
|
54
|
+
index.replace Book.new(1, "Title New", "Author New")
|
55
|
+
|
56
|
+
books.search('Ne').ids.should == [1, 1]
|
57
|
+
end
|
58
|
+
it 'handles more complex cases' do
|
59
|
+
books.search('Ne').ids.should == []
|
60
|
+
|
61
|
+
index.replace Book.new(1, "Title New", "Author New")
|
62
|
+
|
63
|
+
books.search('title:Ne').ids.should == [1]
|
64
|
+
end
|
65
|
+
it 'handles more complex cases' do
|
66
|
+
index.remove 1
|
67
|
+
|
68
|
+
books.search('Titl').ids.should == []
|
69
|
+
|
70
|
+
index.replace Book.new(1, "Title New", "Author New")
|
71
|
+
|
72
|
+
books.search('title:Ne').ids.should == [1]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'non-partial' do
|
77
|
+
it 'finds the first entry' do
|
78
|
+
books.search('Titl').ids.should == [1]
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'allows removing something' do
|
82
|
+
index.remove 1
|
83
|
+
end
|
84
|
+
it 'is not findable anymore after removing' do
|
85
|
+
books.search('Titl').ids.should == [1]
|
86
|
+
|
87
|
+
index.remove 1
|
88
|
+
|
89
|
+
books.search('Titl').ids.should == []
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'allows adding something' do
|
93
|
+
index.add Book.new(2, "Title2", "Author2")
|
94
|
+
end
|
95
|
+
it 'is findable after adding' do
|
96
|
+
books.search('Titl').ids.should == [1]
|
97
|
+
|
98
|
+
index.add Book.new(2, "Title New", "Author New")
|
99
|
+
|
100
|
+
books.search('Titl').ids.should == [2,1]
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'allows replacing something' do
|
104
|
+
index.replace Book.new(1, "Title New", "Author New")
|
105
|
+
end
|
106
|
+
it 'is findable after replacing' do
|
107
|
+
books.search('Ne').ids.should == []
|
108
|
+
|
109
|
+
index.replace Book.new(1, "Title New", "Author New")
|
110
|
+
|
111
|
+
books.search('Ne').ids.should == [1, 1]
|
112
|
+
end
|
113
|
+
it 'handles more complex cases' do
|
114
|
+
books.search('Ne').ids.should == []
|
115
|
+
|
116
|
+
index.replace Book.new(1, "Title New", "Author New")
|
117
|
+
|
118
|
+
books.search('title:Ne').ids.should == [1]
|
119
|
+
end
|
120
|
+
it 'handles more complex cases' do
|
121
|
+
index.remove 1
|
122
|
+
|
123
|
+
books.search('Title"').ids.should == []
|
124
|
+
|
125
|
+
index.replace Book.new(1, "Title New", "Author New")
|
126
|
+
|
127
|
+
books.search('title:New"').ids.should == [1]
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
metadata
CHANGED
@@ -1,49 +1,47 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: picky
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.1.10
|
4
5
|
prerelease:
|
5
|
-
version: 3.1.9
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Florian Hanke
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
date: 2011-10-12 00:00:00 +02:00
|
12
|
+
date: 2011-10-24 00:00:00.000000000 +11:00
|
14
13
|
default_executable: picky
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
17
16
|
name: rspec
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &70166319035880 !ruby/object:Gem::Requirement
|
20
18
|
none: false
|
21
|
-
requirements:
|
22
|
-
- -
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version:
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
25
23
|
type: :development
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: picky-client
|
29
24
|
prerelease: false
|
30
|
-
|
25
|
+
version_requirements: *70166319035880
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: picky-client
|
28
|
+
requirement: &70166319034820 !ruby/object:Gem::Requirement
|
31
29
|
none: false
|
32
|
-
requirements:
|
33
|
-
- -
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 3.1.
|
30
|
+
requirements:
|
31
|
+
- - =
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.1.10
|
36
34
|
type: :development
|
37
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *70166319034820
|
38
37
|
description: Fast Ruby semantic text search engine with comfortable single field interface.
|
39
38
|
email: florian.hanke+picky@gmail.com
|
40
|
-
executables:
|
39
|
+
executables:
|
41
40
|
- picky
|
42
|
-
extensions:
|
41
|
+
extensions:
|
43
42
|
- lib/picky/ext/ruby19/extconf.rb
|
44
43
|
extra_rdoc_files: []
|
45
|
-
|
46
|
-
files:
|
44
|
+
files:
|
47
45
|
- aux/picky/cli.rb
|
48
46
|
- lib/picky/adapters/rack/base.rb
|
49
47
|
- lib/picky/adapters/rack/live_parameters.rb
|
@@ -72,9 +70,11 @@ files:
|
|
72
70
|
- lib/picky/categories.rb
|
73
71
|
- lib/picky/categories_indexed.rb
|
74
72
|
- lib/picky/categories_indexing.rb
|
73
|
+
- lib/picky/categories_realtime.rb
|
75
74
|
- lib/picky/category.rb
|
76
75
|
- lib/picky/category_indexed.rb
|
77
76
|
- lib/picky/category_indexing.rb
|
77
|
+
- lib/picky/category_realtime.rb
|
78
78
|
- lib/picky/character_substituters/west_european.rb
|
79
79
|
- lib/picky/constants.rb
|
80
80
|
- lib/picky/cores.rb
|
@@ -113,7 +113,9 @@ files:
|
|
113
113
|
- lib/picky/index.rb
|
114
114
|
- lib/picky/index_indexed.rb
|
115
115
|
- lib/picky/index_indexing.rb
|
116
|
+
- lib/picky/index_realtime.rb
|
116
117
|
- lib/picky/indexed/bundle.rb
|
118
|
+
- lib/picky/indexed/bundle_realtime.rb
|
117
119
|
- lib/picky/indexed/wrappers/bundle/calculation.rb
|
118
120
|
- lib/picky/indexed/wrappers/bundle/location.rb
|
119
121
|
- lib/picky/indexed/wrappers/bundle/wrapper.rb
|
@@ -221,7 +223,8 @@ files:
|
|
221
223
|
- spec/lib/index_indexed_spec.rb
|
222
224
|
- spec/lib/index_indexing_spec.rb
|
223
225
|
- spec/lib/index_spec.rb
|
224
|
-
- spec/lib/indexed/
|
226
|
+
- spec/lib/indexed/bundle_realtime_spec.rb
|
227
|
+
- spec/lib/indexed/bundle_spec.rb
|
225
228
|
- spec/lib/indexed/wrappers/bundle/calculation_spec.rb
|
226
229
|
- spec/lib/indexed/wrappers/bundle/wrapper_spec.rb
|
227
230
|
- spec/lib/indexed/wrappers/exact_first_spec.rb
|
@@ -263,37 +266,35 @@ files:
|
|
263
266
|
- spec/lib/statistics_spec.rb
|
264
267
|
- spec/lib/tasks/try_spec.rb
|
265
268
|
- spec/lib/tokenizer_spec.rb
|
269
|
+
- spec/specific/realtime_spec.rb
|
266
270
|
- spec/specific/speed_spec.rb
|
267
271
|
- bin/picky
|
268
272
|
has_rdoc: true
|
269
|
-
homepage: http://
|
273
|
+
homepage: http://florianhanke.com/picky
|
270
274
|
licenses: []
|
271
|
-
|
272
275
|
post_install_message:
|
273
276
|
rdoc_options: []
|
274
|
-
|
275
|
-
require_paths:
|
277
|
+
require_paths:
|
276
278
|
- lib
|
277
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
279
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
278
280
|
none: false
|
279
|
-
requirements:
|
280
|
-
- -
|
281
|
-
- !ruby/object:Gem::Version
|
282
|
-
version:
|
283
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
281
|
+
requirements:
|
282
|
+
- - ! '>='
|
283
|
+
- !ruby/object:Gem::Version
|
284
|
+
version: '0'
|
285
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
284
286
|
none: false
|
285
|
-
requirements:
|
286
|
-
- -
|
287
|
-
- !ruby/object:Gem::Version
|
288
|
-
version:
|
287
|
+
requirements:
|
288
|
+
- - ! '>='
|
289
|
+
- !ruby/object:Gem::Version
|
290
|
+
version: '0'
|
289
291
|
requirements: []
|
290
|
-
|
291
292
|
rubyforge_project: http://rubyforge.org/projects/picky
|
292
|
-
rubygems_version: 1.
|
293
|
+
rubygems_version: 1.6.2
|
293
294
|
signing_key:
|
294
295
|
specification_version: 3
|
295
|
-
summary:
|
296
|
-
test_files:
|
296
|
+
summary: ! 'Picky: Semantic Search Engine. Clever Interface. Good Tools.'
|
297
|
+
test_files:
|
297
298
|
- spec/aux/picky/cli_spec.rb
|
298
299
|
- spec/ext/performant_spec.rb
|
299
300
|
- spec/lib/adapters/rack/base_spec.rb
|
@@ -345,7 +346,8 @@ test_files:
|
|
345
346
|
- spec/lib/index_indexed_spec.rb
|
346
347
|
- spec/lib/index_indexing_spec.rb
|
347
348
|
- spec/lib/index_spec.rb
|
348
|
-
- spec/lib/indexed/
|
349
|
+
- spec/lib/indexed/bundle_realtime_spec.rb
|
350
|
+
- spec/lib/indexed/bundle_spec.rb
|
349
351
|
- spec/lib/indexed/wrappers/bundle/calculation_spec.rb
|
350
352
|
- spec/lib/indexed/wrappers/bundle/wrapper_spec.rb
|
351
353
|
- spec/lib/indexed/wrappers/exact_first_spec.rb
|
@@ -387,4 +389,5 @@ test_files:
|
|
387
389
|
- spec/lib/statistics_spec.rb
|
388
390
|
- spec/lib/tasks/try_spec.rb
|
389
391
|
- spec/lib/tokenizer_spec.rb
|
392
|
+
- spec/specific/realtime_spec.rb
|
390
393
|
- spec/specific/speed_spec.rb
|