xapit 0.2.7 → 0.3.0
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/{CHANGELOG → CHANGELOG.rdoc} +7 -2
- data/Gemfile +19 -0
- data/LICENSE +4 -4
- data/README.rdoc +61 -108
- data/Rakefile +11 -10
- data/features/facets.feature +93 -82
- data/features/finding.feature +196 -138
- data/features/indexing.feature +35 -37
- data/features/remote_server.feature +10 -0
- data/features/step_definitions/xapit_steps.rb +53 -25
- data/features/suggestions.feature +20 -14
- data/features/support/env.rb +13 -6
- data/features/support/xapit_helpers.rb +8 -9
- data/lib/generators/xapit/install_generator.rb +14 -0
- data/lib/generators/xapit/templates/xapit.ru +6 -0
- data/lib/generators/xapit/templates/xapit.yml +11 -0
- data/lib/xapit.rb +106 -64
- data/lib/xapit/client/collection.rb +150 -0
- data/lib/xapit/client/facet.rb +11 -0
- data/lib/xapit/client/facet_option.rb +29 -0
- data/lib/xapit/client/index_builder.rb +67 -0
- data/lib/xapit/client/membership.rb +46 -0
- data/lib/xapit/client/model_adapters/abstract_model_adapter.rb +30 -0
- data/lib/xapit/client/model_adapters/active_record_adapter.rb +27 -0
- data/lib/xapit/client/model_adapters/default_model_adapter.rb +7 -0
- data/lib/xapit/client/railtie.rb +18 -0
- data/lib/xapit/client/remote_database.rb +21 -0
- data/lib/xapit/client/tasks.rb +18 -0
- data/lib/xapit/server/app.rb +27 -0
- data/lib/xapit/server/database.rb +47 -0
- data/lib/xapit/server/indexer.rb +138 -0
- data/lib/xapit/server/query.rb +240 -0
- data/spec/fixtures/blankdb/flintlock +0 -0
- data/spec/fixtures/blankdb/iamchert +1 -0
- data/spec/fixtures/blankdb/postlist.DB +0 -0
- data/spec/fixtures/blankdb/postlist.baseA +0 -0
- data/spec/fixtures/blankdb/record.DB +0 -0
- data/spec/fixtures/blankdb/record.baseA +0 -0
- data/spec/fixtures/blankdb/termlist.DB +0 -0
- data/spec/fixtures/blankdb/termlist.baseA +0 -0
- data/spec/fixtures/xapit.ru +13 -0
- data/spec/fixtures/xapit.yml +4 -0
- data/spec/spec_helper.rb +8 -9
- data/spec/support/spec_macros.rb +6 -0
- data/spec/{xapit_member.rb → support/xapit_member.rb} +14 -16
- data/spec/xapit/client/collection_spec.rb +63 -0
- data/spec/xapit/client/facet_option_spec.rb +26 -0
- data/spec/xapit/client/facet_spec.rb +13 -0
- data/spec/xapit/client/index_builder_spec.rb +66 -0
- data/spec/xapit/client/membership_spec.rb +43 -0
- data/spec/xapit/client/model_adapters/active_record_adapter_spec.rb +62 -0
- data/spec/xapit/client/model_adapters/default_model_adapter_spec.rb +7 -0
- data/spec/xapit/client/remote_database_spec.rb +19 -0
- data/spec/xapit/server/app_spec.rb +22 -0
- data/spec/xapit/server/database_spec.rb +37 -0
- data/spec/xapit/server/indexer_spec.rb +82 -0
- data/spec/xapit/server/query_spec.rb +43 -0
- data/spec/xapit/xapit_spec.rb +28 -0
- metadata +124 -93
- data/Manifest +0 -60
- data/features/sorting.feature +0 -29
- data/init.rb +0 -1
- data/install.rb +0 -8
- data/lib/xapit/adapters/abstract_adapter.rb +0 -47
- data/lib/xapit/adapters/active_record_adapter.rb +0 -20
- data/lib/xapit/adapters/data_mapper_adapter.rb +0 -10
- data/lib/xapit/collection.rb +0 -187
- data/lib/xapit/config.rb +0 -84
- data/lib/xapit/facet.rb +0 -67
- data/lib/xapit/facet_blueprint.rb +0 -59
- data/lib/xapit/facet_option.rb +0 -56
- data/lib/xapit/index_blueprint.rb +0 -147
- data/lib/xapit/indexers/abstract_indexer.rb +0 -116
- data/lib/xapit/indexers/classic_indexer.rb +0 -29
- data/lib/xapit/indexers/simple_indexer.rb +0 -38
- data/lib/xapit/membership.rb +0 -137
- data/lib/xapit/query.rb +0 -89
- data/lib/xapit/query_parsers/abstract_query_parser.rb +0 -174
- data/lib/xapit/query_parsers/classic_query_parser.rb +0 -29
- data/lib/xapit/query_parsers/simple_query_parser.rb +0 -75
- data/lib/xapit/rake_tasks.rb +0 -13
- data/rails_generators/xapit/USAGE +0 -13
- data/rails_generators/xapit/templates/setup_xapit.rb +0 -1
- data/rails_generators/xapit/templates/xapit.rake +0 -4
- data/rails_generators/xapit/xapit_generator.rb +0 -20
- data/spec/xapit/adapters/active_record_adapter_spec.rb +0 -31
- data/spec/xapit/adapters/data_mapper_adapter_spec.rb +0 -10
- data/spec/xapit/collection_spec.rb +0 -176
- data/spec/xapit/config_spec.rb +0 -62
- data/spec/xapit/facet_blueprint_spec.rb +0 -29
- data/spec/xapit/facet_option_spec.rb +0 -80
- data/spec/xapit/facet_spec.rb +0 -73
- data/spec/xapit/index_blueprint_spec.rb +0 -112
- data/spec/xapit/indexers/abstract_indexer_spec.rb +0 -111
- data/spec/xapit/indexers/classic_indexer_spec.rb +0 -35
- data/spec/xapit/indexers/simple_indexer_spec.rb +0 -69
- data/spec/xapit/membership_spec.rb +0 -55
- data/spec/xapit/query_parsers/abstract_query_parser_spec.rb +0 -60
- data/spec/xapit/query_parsers/classic_query_parser_spec.rb +0 -20
- data/spec/xapit/query_parsers/simple_query_parser_spec.rb +0 -86
- data/spec/xapit/query_spec.rb +0 -60
- data/tasks/spec.rb +0 -9
- data/tasks/xapit.rake +0 -1
- data/uninstall.rb +0 -5
- data/xapit.gemspec +0 -30
data/features/finding.feature
CHANGED
|
@@ -1,138 +1,196 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
Scenario: Query
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
1
|
+
Feature: Finding
|
|
2
|
+
|
|
3
|
+
Scenario: Query Matching No Records
|
|
4
|
+
Given indexed records named "John, Jane"
|
|
5
|
+
When I query for "Sam"
|
|
6
|
+
Then I should find 0 records
|
|
7
|
+
|
|
8
|
+
Scenario: Query Matching One Record
|
|
9
|
+
Given indexed records named "John, Jane"
|
|
10
|
+
When I query for "John"
|
|
11
|
+
Then I should find record named "John"
|
|
12
|
+
|
|
13
|
+
Scenario: Query Matching Two Records
|
|
14
|
+
Given indexed records named "John Smith, Jane Smith, John Smithsonian"
|
|
15
|
+
When I query for "Smith"
|
|
16
|
+
Then I should find records named "John Smith, Jane Smith"
|
|
17
|
+
|
|
18
|
+
Scenario: Query for All Records Class Agnostic
|
|
19
|
+
Given indexed records named "John, Jane"
|
|
20
|
+
When I query for "John" on Xapit
|
|
21
|
+
Then I should find 1 record
|
|
22
|
+
|
|
23
|
+
Scenario: Query Field Matching
|
|
24
|
+
Given the following indexed records
|
|
25
|
+
| name | age |
|
|
26
|
+
| John | 23 |
|
|
27
|
+
| Jane | 17 |
|
|
28
|
+
| Jack | 17 |
|
|
29
|
+
When I query "age" matching "17"
|
|
30
|
+
Then I should find records named "Jane, Jack"
|
|
31
|
+
|
|
32
|
+
Scenario: Query Text and Field Matching
|
|
33
|
+
Given the following indexed records
|
|
34
|
+
| name | age |
|
|
35
|
+
| Jane | 23 |
|
|
36
|
+
| Jane | 17 |
|
|
37
|
+
| Jack | 17 |
|
|
38
|
+
When I query for "Jane" and "age" matching "17"
|
|
39
|
+
Then I should find records named "Jane"
|
|
40
|
+
|
|
41
|
+
Scenario: Query Field Not Matching
|
|
42
|
+
Given the following indexed records
|
|
43
|
+
| name | age |
|
|
44
|
+
| John | 23 |
|
|
45
|
+
| Jane | 17 |
|
|
46
|
+
| Jack | 17 |
|
|
47
|
+
When I query "age" not matching "17"
|
|
48
|
+
Then I should find records named "John"
|
|
49
|
+
|
|
50
|
+
Scenario: Query for separate OR conditions
|
|
51
|
+
Given the following indexed records
|
|
52
|
+
| name | age |
|
|
53
|
+
| John | 23 |
|
|
54
|
+
| Jane | 17 |
|
|
55
|
+
| Jack | 18 |
|
|
56
|
+
When I query "age" matching "17" or "name" matching "Jack"
|
|
57
|
+
Then I should find records named "Jane, Jack"
|
|
58
|
+
|
|
59
|
+
Scenario: Query Matching Or Query
|
|
60
|
+
Given indexed records named "John, Jane, Jacob"
|
|
61
|
+
When I query for "Jane OR John"
|
|
62
|
+
Then I should find records named "John, Jane"
|
|
63
|
+
|
|
64
|
+
Scenario: Query Matching Not Query
|
|
65
|
+
Given indexed records named "John Smith, John Johnson"
|
|
66
|
+
When I query for "John NOT Smith"
|
|
67
|
+
Then I should find records named "John Johnson"
|
|
68
|
+
|
|
69
|
+
Scenario: Unicode characters in search
|
|
70
|
+
Given indexed records named "über cool, uber hot"
|
|
71
|
+
When I query for "über"
|
|
72
|
+
Then I should find records named "über cool"
|
|
73
|
+
|
|
74
|
+
Scenario: Query for All Records Sorted by Name
|
|
75
|
+
Given indexed records named "Zebra, Apple, Banana"
|
|
76
|
+
When I query "" sorted by name
|
|
77
|
+
Then I should find records named "Apple, Banana, Zebra"
|
|
78
|
+
|
|
79
|
+
Scenario: Query for All Records Sorted by Age then Name
|
|
80
|
+
Given the following indexed records
|
|
81
|
+
| name | age |
|
|
82
|
+
| Banana | 23 |
|
|
83
|
+
| Zebra | 17 |
|
|
84
|
+
| Apple | 17 |
|
|
85
|
+
When I query "" sorted by age, name
|
|
86
|
+
Then I should find records named "Apple, Zebra, Banana"
|
|
87
|
+
|
|
88
|
+
Scenario: Query for All Records Sorted by Name Descending
|
|
89
|
+
Given indexed records named "Zebra, Apple, Banana"
|
|
90
|
+
When I query "" sorted by name descending
|
|
91
|
+
Then I should find records named "Zebra, Banana, Apple"
|
|
92
|
+
|
|
93
|
+
Scenario: Query for Records Sorted Numerically
|
|
94
|
+
Given the following indexed records
|
|
95
|
+
| name | age |
|
|
96
|
+
| Banana | 9 |
|
|
97
|
+
| Zebra | 10 |
|
|
98
|
+
When I query "" sorted by age, name
|
|
99
|
+
Then I should find records named "Banana, Zebra"
|
|
100
|
+
|
|
101
|
+
Scenario: Query for Page 1
|
|
102
|
+
Given 3 indexed records
|
|
103
|
+
When I query page 1 at 2 per page
|
|
104
|
+
Then I should find 2 records
|
|
105
|
+
|
|
106
|
+
Scenario: Query for Page 2
|
|
107
|
+
Given 3 indexed records
|
|
108
|
+
When I query page 2 at 2 per page
|
|
109
|
+
Then I should find 1 record
|
|
110
|
+
And I should have 3 records total
|
|
111
|
+
|
|
112
|
+
Scenario: Query Range of Integer
|
|
113
|
+
Given the following indexed records
|
|
114
|
+
| name | age |
|
|
115
|
+
| John | 8 |
|
|
116
|
+
| Jane | 13 |
|
|
117
|
+
| Jack | 24 |
|
|
118
|
+
When I query "age" between 8 and 15
|
|
119
|
+
Then I should find records named "John, Jane"
|
|
120
|
+
|
|
121
|
+
Scenario: Query for condition in keywords string
|
|
122
|
+
Given the following indexed records
|
|
123
|
+
| name | age |
|
|
124
|
+
| John | 23 |
|
|
125
|
+
| Jane | 17 |
|
|
126
|
+
| Jack | 17 |
|
|
127
|
+
When I query for "age:17"
|
|
128
|
+
Then I should find records named "Jane, Jack"
|
|
129
|
+
|
|
130
|
+
Scenario: Query for separate OR conditions and keywords
|
|
131
|
+
Given the following indexed records
|
|
132
|
+
| name | age |
|
|
133
|
+
| John | 23 |
|
|
134
|
+
| Jane | 17 |
|
|
135
|
+
| Jack | 18 |
|
|
136
|
+
When I query for "John" or "age" matching "18" ordered by "name"
|
|
137
|
+
Then I should find records named "Jack, John"
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
Scenario: Query partial match in keywords
|
|
141
|
+
Given the following indexed records
|
|
142
|
+
| name | sirname |
|
|
143
|
+
| John | Jacobson |
|
|
144
|
+
| Bill | Niel |
|
|
145
|
+
| Jack | Striker |
|
|
146
|
+
When I query for "Ja*"
|
|
147
|
+
Then I should find records named "John, Jack"
|
|
148
|
+
|
|
149
|
+
Scenario: Query no partial match in keywords with one letter
|
|
150
|
+
Given the following indexed records
|
|
151
|
+
| name | sirname |
|
|
152
|
+
| John | Jacobson |
|
|
153
|
+
| Bill | Niel |
|
|
154
|
+
| Jack | J |
|
|
155
|
+
When I query for "J*"
|
|
156
|
+
Then I should find records named "Jack"
|
|
157
|
+
|
|
158
|
+
Scenario: Query no stemming
|
|
159
|
+
Given indexed records named "runs, sat, sits"
|
|
160
|
+
And no stemming
|
|
161
|
+
When I query for "run"
|
|
162
|
+
Then I should find 0 records
|
|
163
|
+
|
|
164
|
+
Scenario: Query with stemming by default
|
|
165
|
+
Given indexed records named "runs, sat, sits"
|
|
166
|
+
When I query for "run"
|
|
167
|
+
Then I should find records named "runs"
|
|
168
|
+
|
|
169
|
+
Scenario: Query ignore punctuation in keyword
|
|
170
|
+
Given the following indexed records
|
|
171
|
+
| name | sirname |
|
|
172
|
+
| Jack | John-son's |
|
|
173
|
+
| Bill | Johnsons |
|
|
174
|
+
| Jane | Johnson |
|
|
175
|
+
When I query for "Johnsons"
|
|
176
|
+
Then I should find records named "Jack, Bill"
|
|
177
|
+
When I query for "Jo-hn'sons"
|
|
178
|
+
Then I should find records named "Jack, Bill"
|
|
179
|
+
|
|
180
|
+
# Scenario: Query Partial Match on Condition
|
|
181
|
+
# Given the following indexed records
|
|
182
|
+
# | name | sirname |
|
|
183
|
+
# | John | Jacobson |
|
|
184
|
+
# | Jane | Niel |
|
|
185
|
+
# | Jack | Striker |
|
|
186
|
+
# When I query "name" matching "Ja*"
|
|
187
|
+
# Then I should find records named "Jane, Jack"
|
|
188
|
+
#
|
|
189
|
+
# Scenario: Query no partial match on conditions with one letter
|
|
190
|
+
# Given the following indexed records
|
|
191
|
+
# | name | sirname |
|
|
192
|
+
# | John | Jacobson |
|
|
193
|
+
# | Jane | Niel |
|
|
194
|
+
# | Jack | Striker |
|
|
195
|
+
# When I query "name" matching " J*"
|
|
196
|
+
# Then I should find 0 records
|
data/features/indexing.feature
CHANGED
|
@@ -1,41 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
Given no file exists at "tmp/xapiandb"
|
|
3
|
-
And I configured the database to be saved at "tmp/xapiandb"
|
|
4
|
-
And 3 records
|
|
5
|
-
When I index the database
|
|
6
|
-
Then I should find a directory at "tmp/xapiandb"
|
|
1
|
+
Feature: Indexing
|
|
7
2
|
|
|
8
|
-
Scenario:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
Scenario: Save xapian database on index
|
|
4
|
+
Given no file exists at "tmp/testdb"
|
|
5
|
+
And an empty database at "tmp/testdb"
|
|
6
|
+
And 3 records
|
|
7
|
+
When I index the database
|
|
8
|
+
Then I should find a directory at "tmp/testdb"
|
|
14
9
|
|
|
15
|
-
Scenario:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Then I should find records named "JohnXSmith, JaneXSmith"
|
|
10
|
+
Scenario: Fetch all records which are indexed
|
|
11
|
+
And records named "John, Jane, Joe"
|
|
12
|
+
When I index the database
|
|
13
|
+
And I query for ""
|
|
14
|
+
Then I should find records named "John, Jane, Joe"
|
|
21
15
|
|
|
22
|
-
Scenario: Index Multiple Field Values Separately
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
Then I should find records named "Jane, John"
|
|
16
|
+
Scenario: Index Multiple Field Values Separately
|
|
17
|
+
And the following indexed records
|
|
18
|
+
| name | age |
|
|
19
|
+
| John | 17, 16 |
|
|
20
|
+
| Jack | 17 |
|
|
21
|
+
| Jane | 16 |
|
|
22
|
+
When I query "age" matching "16"
|
|
23
|
+
Then I should find records named "Jane, John"
|
|
31
24
|
|
|
32
|
-
Scenario: Index Weighted Attributes
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
25
|
+
Scenario: Index Weighted Attributes
|
|
26
|
+
And the following indexed records with "name" weighted by "10"
|
|
27
|
+
| name | description |
|
|
28
|
+
| foo | bar |
|
|
29
|
+
| bar | foo |
|
|
30
|
+
When I query for "bar"
|
|
31
|
+
Then I should find records named "bar, foo"
|
|
32
|
+
When I query for "foo"
|
|
33
|
+
Then I should find records named "foo, bar"
|
|
34
|
+
|
|
35
|
+
Scenario: Split indexed text fields differently
|
|
36
|
+
And records named "JohnXSmith, JaneXSmith, JoeXBlack"
|
|
37
|
+
When I index the database splitting name by "X"
|
|
38
|
+
And I query for "Smith"
|
|
39
|
+
Then I should find records named "JohnXSmith, JaneXSmith"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Feature: Remote Server
|
|
2
|
+
#
|
|
3
|
+
# Background:
|
|
4
|
+
# Given a remote database
|
|
5
|
+
#
|
|
6
|
+
# Scenario: Basic index and search
|
|
7
|
+
# Given records named "John Smith, John Doe, Jane, Joe"
|
|
8
|
+
# When I index the database
|
|
9
|
+
# And I query for "John"
|
|
10
|
+
# Then I should find records named "John Smith, John Doe"
|
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
Given /^
|
|
2
|
-
|
|
1
|
+
Given /^an empty database at "([^\"]*)"$/ do |path|
|
|
2
|
+
path = File.expand_path("../../../#{path}", __FILE__)
|
|
3
|
+
template = File.expand_path("../../../spec/fixtures/blankdb", __FILE__)
|
|
4
|
+
FileUtils.rm_rf(path) if File.exist? path
|
|
5
|
+
FileUtils.cp_r(template, path)
|
|
6
|
+
Xapit.config[:database_path] = path
|
|
7
|
+
XapitMember.delete_all
|
|
8
|
+
GC.start
|
|
3
9
|
end
|
|
4
10
|
|
|
5
|
-
Given /^
|
|
6
|
-
|
|
7
|
-
Xapit.
|
|
11
|
+
Given /^a remote database$/ do
|
|
12
|
+
$server = IO.popen("rackup spec/fixtures/xapit.ru -p 9797") if $server.nil?
|
|
13
|
+
Xapit.reset_config
|
|
14
|
+
Xapit.config[:server] = "http://localhost:9797"
|
|
8
15
|
XapitMember.delete_all
|
|
16
|
+
sleep 5
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Given /^no stemming$/ do
|
|
20
|
+
Xapit.config[:stemming] = nil
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Given /^spelling is enabled$/ do
|
|
24
|
+
Xapit.config[:spelling] = true
|
|
9
25
|
end
|
|
10
26
|
|
|
11
27
|
Given /^(indexed )?records? named "([^\"]*)"$/ do |indexed, joined_names|
|
|
@@ -32,14 +48,18 @@ Given /^the following indexed records with "([^\"]*)" weighted by "([^\"]*)"$/ d
|
|
|
32
48
|
end
|
|
33
49
|
|
|
34
50
|
When /^I index the database$/ do
|
|
35
|
-
|
|
51
|
+
XapitMember.find_each do |member|
|
|
52
|
+
member.class.xapit_index_builder.add_document(member)
|
|
53
|
+
end
|
|
36
54
|
end
|
|
37
55
|
|
|
38
56
|
When /^I index the database splitting name by "([^\"]*)"$/ do |divider|
|
|
39
57
|
XapitMember.xapit do |index|
|
|
40
58
|
index.text(:name) { |name| name.split(divider) }
|
|
41
59
|
end
|
|
42
|
-
|
|
60
|
+
XapitMember.find_each do |member|
|
|
61
|
+
member.class.xapit_index_builder.add_document(member)
|
|
62
|
+
end
|
|
43
63
|
end
|
|
44
64
|
|
|
45
65
|
When /^I query for "([^\"]*)"$/ do |query|
|
|
@@ -51,51 +71,58 @@ When /^I query for "([^\"]*)" on Xapit$/ do |query|
|
|
|
51
71
|
end
|
|
52
72
|
|
|
53
73
|
When /^I query "([^\"]*)" with facets "([^\"]*)"$/ do |keywords, facets|
|
|
54
|
-
@records = XapitMember.search(keywords
|
|
74
|
+
@records = XapitMember.search(keywords).with_facets(facets)
|
|
55
75
|
end
|
|
56
76
|
|
|
57
77
|
Then /^I should find records? named "([^\"]*)"$/ do |joined_names|
|
|
58
|
-
@records.map(&:name).join(", ").should
|
|
78
|
+
@records.map(&:name).join(", ").should eq(joined_names)
|
|
59
79
|
end
|
|
60
80
|
|
|
61
81
|
Then /^I should find ([0-9]+) records?$/ do |num|
|
|
62
|
-
@records.should
|
|
82
|
+
@records.records.size.should eq(num.to_i)
|
|
63
83
|
end
|
|
64
84
|
|
|
65
85
|
Then /^I should have ([0-9]+) records? total$/ do |num|
|
|
66
|
-
@records.total_entries.should
|
|
86
|
+
@records.total_entries.should eq(num.to_i)
|
|
67
87
|
end
|
|
68
88
|
|
|
69
89
|
When /^I query "([^\"]*)" matching "([^\"]*)"$/ do |field, value|
|
|
70
|
-
@records = XapitMember.search(
|
|
90
|
+
@records = XapitMember.search.where(field.to_sym => value)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
When /^I query for "([^\"]*)" and "([^\"]*)" matching "([^\"]*)"$/ do |text, field, value|
|
|
94
|
+
@records = XapitMember.search(text).where(field.to_sym => value)
|
|
71
95
|
end
|
|
72
96
|
|
|
73
97
|
When /^I query "([^\"]*)" not matching "([^\"]*)"$/ do |field, value|
|
|
74
|
-
@records = XapitMember.search(
|
|
98
|
+
@records = XapitMember.search.not_where(field.to_sym => value)
|
|
75
99
|
end
|
|
76
100
|
|
|
77
101
|
When /^I query "([^\"]*)" matching "([^\"]*)" or "([^\"]*)" matching "([^\"]*)"$/ do |field1, value1, field2, value2|
|
|
78
|
-
@records = XapitMember.search(
|
|
102
|
+
@records = XapitMember.search.where(field1.to_sym => value1).or_where(field2.to_sym => value2)
|
|
79
103
|
end
|
|
80
104
|
|
|
81
105
|
When /^I query for "([^\"]*)" or "([^\"]*)" matching "([^\"]*)" ordered by "([^\"]*)"$/ do |keywords, field, value, order|
|
|
82
|
-
@records = XapitMember.search(keywords
|
|
106
|
+
@records = XapitMember.search(keywords).order(order).or_where(field.to_sym => value)
|
|
83
107
|
end
|
|
84
108
|
|
|
85
109
|
When /^I query "([^\"]*)" between (\d+) and (\d+)$/ do |field, beginning, ending|
|
|
86
|
-
@records = XapitMember.search(
|
|
110
|
+
@records = XapitMember.search.where(field.to_sym => beginning.to_i..ending.to_i)
|
|
87
111
|
end
|
|
88
112
|
|
|
89
113
|
When /^I query page ([0-9]+) at ([0-9]+) per page$/ do |page, per_page|
|
|
90
|
-
@records = XapitMember.search(
|
|
114
|
+
@records = XapitMember.search.page(page).per(per_page)
|
|
91
115
|
end
|
|
92
116
|
|
|
93
117
|
When /^I query facets "([^\"]*)"$/ do |facets|
|
|
94
|
-
@records = XapitMember.search(
|
|
118
|
+
@records = XapitMember.search.with_facets(facets)
|
|
95
119
|
end
|
|
96
120
|
|
|
97
121
|
When /^I query "([^\"]*)" sorted by (.*?)( descending)?$/ do |keywords, sort, descending|
|
|
98
|
-
@records = XapitMember.search
|
|
122
|
+
@records = XapitMember.search
|
|
123
|
+
sort.split(', ').each do |sort|
|
|
124
|
+
@records = @records.order(sort, (descending ? :desc : :asc))
|
|
125
|
+
end
|
|
99
126
|
end
|
|
100
127
|
|
|
101
128
|
When /^I query for similar records for "([^\"]*)"$/ do |keywords|
|
|
@@ -106,28 +133,29 @@ Then /^I should have the following facets$/ do |facets_table|
|
|
|
106
133
|
result = []
|
|
107
134
|
@records.facets.each do |facet|
|
|
108
135
|
facet.options.each do |option|
|
|
109
|
-
|
|
136
|
+
hash = {
|
|
110
137
|
"facet" => facet.name,
|
|
111
138
|
"option" => option.name,
|
|
112
139
|
"count" => option.count.to_s
|
|
113
140
|
}
|
|
141
|
+
hash["param"] = option.to_param if facets_table.headers.include? "param"
|
|
142
|
+
result << hash
|
|
114
143
|
end
|
|
115
144
|
end
|
|
116
|
-
result.should
|
|
145
|
+
result.map(&:inspect).sort.should eq(facets_table.hashes.map(&:inspect).sort)
|
|
117
146
|
end
|
|
118
147
|
|
|
119
148
|
Then /^I should have the following applied facets$/ do |facets_table|
|
|
120
149
|
result = []
|
|
121
150
|
@records.applied_facet_options.each do |option|
|
|
122
151
|
result << {
|
|
123
|
-
"facet" => option.
|
|
152
|
+
"facet" => option.attribute.sub(/^(.)/) { |c| c.upcase }, # quick hack
|
|
124
153
|
"option" => option.name
|
|
125
154
|
}
|
|
126
155
|
end
|
|
127
|
-
result.should
|
|
156
|
+
result.map(&:inspect).sort.should eq(facets_table.hashes.map(&:inspect).sort)
|
|
128
157
|
end
|
|
129
158
|
|
|
130
159
|
Then /^I should have "([^\"]*)" as a spelling suggestion$/ do |term|
|
|
131
|
-
@records.spelling_suggestion.should
|
|
160
|
+
@records.spelling_suggestion.to_s.should eq(term)
|
|
132
161
|
end
|
|
133
|
-
|