oedipus-dm 0.0.1 → 0.0.2
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/README.md +60 -7
- data/lib/oedipus/data_mapper/index.rb +1 -1
- data/lib/oedipus/data_mapper/version.rb +1 -1
- data/spec/integration/index_spec.rb +17 -0
- metadata +18 -12
data/README.md
CHANGED
@@ -1,15 +1,41 @@
|
|
1
1
|
# Oedipus Sphinx Integration for DataMapper
|
2
2
|
|
3
|
-
This gem
|
4
|
-
|
3
|
+
This gem provides a binding between
|
4
|
+
[Oedipus](https://github.com/d11wtq/oedipus) and
|
5
|
+
[DataMapper](https://github.com/datamapper/dm-core), in order to support
|
5
6
|
the querying and updating of Sphinx indexes through DataMapper models.
|
6
7
|
|
7
|
-
|
8
|
+
Oedipus provides a clean interface with Sphinx 2, allowing the use of
|
9
|
+
realtime indexes and multi-dimensional faceted search via ruby.
|
10
|
+
|
11
|
+
- [Requirements](#requirements)
|
12
|
+
- [Installation](#installation)
|
13
|
+
- [Usage](#usage)
|
14
|
+
- [Configure oedipus](#configure-oedipus)
|
15
|
+
- [Defining an index](#defining-an-index)
|
16
|
+
- [Fulltext search](#fulltext-search-for-resources-via-the-index)
|
17
|
+
- [Faceted search](#faceted-search)
|
18
|
+
- [Parallel search](#performing-multiple-searches-in-parallel)
|
19
|
+
- [Realtime index management](#realtime-index-management)
|
20
|
+
- [Integration with dm-pager](#integration-with-dm-pager-aka-dm-pagination)
|
21
|
+
- [Talking direcly to Oedipus](#talking-directly-to-oedipus)
|
22
|
+
|
23
|
+
## Requirements
|
24
|
+
|
25
|
+
- Sphinx >= 2.0.2
|
26
|
+
- Ruby >= 1.9
|
27
|
+
- Mysql client development libraries
|
28
|
+
|
29
|
+
## Installation
|
30
|
+
|
31
|
+
Via rubygems
|
32
|
+
|
33
|
+
gem install oedipus-dm
|
8
34
|
|
9
35
|
## Usage
|
10
36
|
|
11
|
-
All features of
|
12
|
-
|
37
|
+
All features of the main oedipus gem are supported, with some allowance for
|
38
|
+
the use of DataMapper's operators etc.
|
13
39
|
|
14
40
|
### Configure Oedipus
|
15
41
|
|
@@ -218,12 +244,16 @@ loaded. This is on my radar, however.
|
|
218
244
|
### Faceted Search
|
219
245
|
|
220
246
|
Oedipus makes faceted searches really easy. Pass in a `:facets` option, as a
|
221
|
-
Hash, where each key
|
222
|
-
Oedipus provides the results for each facet nested inside the collection.
|
247
|
+
Hash, where each key identifies the facet and the value lists the arguments,
|
248
|
+
then Oedipus provides the results for each facet nested inside the collection.
|
223
249
|
|
224
250
|
Each facet inherits the base search, which it may override in some way, such as
|
225
251
|
filtering by an attribute, or modifying the fulltext query itself.
|
226
252
|
|
253
|
+
The key used to identify the facet can be any arbitrary object, which may be
|
254
|
+
useful in some application-specific contexts, where the key can carry associated
|
255
|
+
domain-specific data.
|
256
|
+
|
227
257
|
``` ruby
|
228
258
|
posts = Post.index.search(
|
229
259
|
"badgers",
|
@@ -262,6 +292,29 @@ Oedipus replaces `%{query}` in your facets with whatever the base query was,
|
|
262
292
|
which is useful if you want to amend the search, rather than completely
|
263
293
|
overwrite it (which is also possible).
|
264
294
|
|
295
|
+
#### Faceted search with N dimensions
|
296
|
+
|
297
|
+
Each facet in a faceted search can in turn contain facets of its own. This
|
298
|
+
allows you to perform multi-dimensional faceted searches, where each level
|
299
|
+
deeper adds a new dimension to the search. The equivalent tree is returned in
|
300
|
+
the results.
|
301
|
+
|
302
|
+
``` ruby
|
303
|
+
posts = Post.index.search(
|
304
|
+
"badgers",
|
305
|
+
facets: {
|
306
|
+
popular: {
|
307
|
+
:views.gte => 1000,
|
308
|
+
:facets => {
|
309
|
+
in_title: "@title (%{query})",
|
310
|
+
}
|
311
|
+
}
|
312
|
+
}
|
313
|
+
)
|
314
|
+
|
315
|
+
puts "Found #{posts.facets[:popular].facets[:in_title].total_found} popular posts with 'badgers' in title"
|
316
|
+
```
|
317
|
+
|
265
318
|
#### Performance tip
|
266
319
|
|
267
320
|
A common use of faceted search is to provide links to the full listing for
|
@@ -351,6 +351,23 @@ describe Oedipus::DataMapper::Index do
|
|
351
351
|
}
|
352
352
|
).facets[:popular].total_found.should == 2
|
353
353
|
end
|
354
|
+
|
355
|
+
context "in n-dimensions" do
|
356
|
+
it "returns the nested facets inside the child collection" do
|
357
|
+
index.search(
|
358
|
+
"badgers",
|
359
|
+
order: :id,
|
360
|
+
facets: {
|
361
|
+
popular: {
|
362
|
+
:views.gte => 7,
|
363
|
+
:facets => {
|
364
|
+
running: "%{query} & run"
|
365
|
+
}
|
366
|
+
}
|
367
|
+
}
|
368
|
+
).facets[:popular].facets[:running].total_found.should == 1
|
369
|
+
end
|
370
|
+
end
|
354
371
|
end
|
355
372
|
end
|
356
373
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oedipus-dm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oedipus
|
16
|
-
requirement: &
|
16
|
+
requirement: &13409800 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.0.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *13409800
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: dm-core
|
27
|
-
requirement: &
|
27
|
+
requirement: &13409180 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.2'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *13409180
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &13408800 !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: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *13408800
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &13408340 !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: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *13408340
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: dm-pager
|
60
|
-
requirement: &
|
60
|
+
requirement: &13407860 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *13407860
|
69
69
|
description: ! '== DataMapper Integration for Oedipus
|
70
70
|
|
71
71
|
|
@@ -114,12 +114,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
114
|
- - ! '>='
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
hash: 2073315662830389544
|
117
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
121
|
none: false
|
119
122
|
requirements:
|
120
123
|
- - ! '>='
|
121
124
|
- !ruby/object:Gem::Version
|
122
125
|
version: '0'
|
126
|
+
segments:
|
127
|
+
- 0
|
128
|
+
hash: 2073315662830389544
|
123
129
|
requirements: []
|
124
130
|
rubyforge_project:
|
125
131
|
rubygems_version: 1.8.11
|