picky 4.12.5 → 4.12.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -41,7 +41,9 @@ module Picky
|
|
41
41
|
# ids that have an associated identifier that is nil.
|
42
42
|
#
|
43
43
|
def remove categories = []
|
44
|
-
|
44
|
+
# TODO Do not use the name, but the category.
|
45
|
+
#
|
46
|
+
@combinations.reject! { |combination| categories.include?(combination.category.name) }
|
45
47
|
end
|
46
48
|
|
47
49
|
#
|
@@ -6,6 +6,38 @@ require 'spec_helper'
|
|
6
6
|
#
|
7
7
|
describe 'ignoring allocations/categories' do
|
8
8
|
|
9
|
+
it 'ignores categories/allocations correctly' do
|
10
|
+
index = Picky::Index.new :books do
|
11
|
+
category :author
|
12
|
+
category :title
|
13
|
+
category :text
|
14
|
+
end
|
15
|
+
|
16
|
+
thing = Struct.new :id, :author, :title, :text
|
17
|
+
index.add thing.new(1, 'peter', 'some title', 'some text')
|
18
|
+
index.add thing.new(2, 'some name', 'some title', 'some text')
|
19
|
+
|
20
|
+
try = Picky::Search.new index do
|
21
|
+
ignore [:author, :text],
|
22
|
+
:text,
|
23
|
+
[:text, :text]
|
24
|
+
end
|
25
|
+
|
26
|
+
# These categories/allocations are now removed.
|
27
|
+
#
|
28
|
+
try.search('some some').allocations.to_result.should == [
|
29
|
+
# [:books, 1.386, 2, [[:text, "some", "some"], [:text, "some", "some"]], [2, 1]],
|
30
|
+
[:books, 1.386, 2, [[:title, "some", "some"]], [2, 1]],
|
31
|
+
[:books, 1.386, 2, [ [:title, "some", "some"]], [2, 1]],
|
32
|
+
[:books, 1.386, 2, [[:title, "some", "some"], [:title, "some", "some"]], [2, 1]],
|
33
|
+
[:books, 0.693, 1, [[:title, "some", "some"], [:author, "some", "some"]], [2]],
|
34
|
+
# [:books, 0.693, 1, [[:author, "some", "some"], [:text, "some", "some"]], [2]],
|
35
|
+
[:books, 0.693, 1, [[:author, "some", "some"], [:title, "some", "some"]], [2]],
|
36
|
+
[:books, 0.693, 1, [ [:author, "some", "some"]], [2]],
|
37
|
+
[:books, 0.0, 1, [[:author, "some", "some"], [:author, "some", "some"]], [2]]
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
9
41
|
it 'ignores allocations correctly' do
|
10
42
|
index = Picky::Index.new :books do
|
11
43
|
category :author
|
@@ -67,4 +99,35 @@ describe 'ignoring allocations/categories' do
|
|
67
99
|
# [:books, 0.0, 1, [[:author, "some", "some"], [:author, "some", "some"]], [2]]
|
68
100
|
]
|
69
101
|
end
|
102
|
+
|
103
|
+
it 'performs far better' do
|
104
|
+
index = Picky::Index.new :books do
|
105
|
+
category :author
|
106
|
+
category :title
|
107
|
+
category :text
|
108
|
+
end
|
109
|
+
|
110
|
+
thing = Struct.new :id, :author, :title, :text
|
111
|
+
index.add thing.new(1, 'peter', 'some title', 'some text')
|
112
|
+
index.add thing.new(2, 'some name', 'some title', 'some text')
|
113
|
+
index.add thing.new(3, 'peter', 'some title', 'some text')
|
114
|
+
index.add thing.new(4, 'some name', 'some title', 'some text')
|
115
|
+
index.add thing.new(5, 'peter', 'some title', 'some text')
|
116
|
+
index.add thing.new(6, 'some name', 'some title', 'some text')
|
117
|
+
index.add thing.new(7, 'peter', 'some title', 'some text')
|
118
|
+
index.add thing.new(8, 'some name', 'some title', 'some text')
|
119
|
+
|
120
|
+
try = Picky::Search.new index
|
121
|
+
|
122
|
+
# Reasonably fast.
|
123
|
+
#
|
124
|
+
performance_of { try.search('some some') }.should < 0.0005
|
125
|
+
|
126
|
+
try.only [:author, :text],
|
127
|
+
[:text, :text]
|
128
|
+
|
129
|
+
# Much faster.
|
130
|
+
#
|
131
|
+
performance_of { try.search('some some') }.should < 0.000175
|
132
|
+
end
|
70
133
|
end
|
@@ -57,9 +57,9 @@ describe Picky::Query::Combinations do
|
|
57
57
|
|
58
58
|
describe 'remove' do
|
59
59
|
before(:each) do
|
60
|
-
@combination1 = stub :combination1, :category => :other
|
61
|
-
@combination2 = stub :combination2, :category => :to_remove
|
62
|
-
@combination3 = stub :combination3, :category => :to_remove
|
60
|
+
@combination1 = stub :combination1, :category => stub(:other, :name => :other)
|
61
|
+
@combination2 = stub :combination2, :category => stub(:to_remove, :name => :to_remove)
|
62
|
+
@combination3 = stub :combination3, :category => stub(:to_remove, :name => :to_remove)
|
63
63
|
|
64
64
|
@combinations = described_class.new [@combination1, @combination2, @combination3]
|
65
65
|
end
|
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.12.
|
4
|
+
version: 4.12.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 4.12.
|
37
|
+
version: 4.12.6
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 4.12.
|
45
|
+
version: 4.12.6
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: text
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|