oedipus-dm 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,15 +1,41 @@
1
1
  # Oedipus Sphinx Integration for DataMapper
2
2
 
3
- This gem is a work in progress, binding [Oedipus](https://github.com/d11wtq/oedipus)
4
- with [DataMapper](https://github.com/datamapper/dm-core), in order to support
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
- The gem is not yet published, as it is still in development.
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 Oedipus will ultimately be supported, but I'm documenting as
12
- I complete wrapping the features.
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 names the facet and the value lists the arguments, then
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
@@ -45,7 +45,7 @@ module Oedipus
45
45
 
46
46
  map(:id, with: @key)
47
47
 
48
- yield self
48
+ yield self if block_given?
49
49
  end
50
50
 
51
51
  # Returns the underlying Index, for carrying out low-level operations.
@@ -9,6 +9,6 @@
9
9
 
10
10
  module Oedipus
11
11
  module DataMapper
12
- VERSION = "0.0.1"
12
+ VERSION = "0.0.2"
13
13
  end
14
14
  end
@@ -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.1
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-04-29 00:00:00.000000000 Z
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: &14446500 !ruby/object:Gem::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: *14446500
24
+ version_requirements: *13409800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: dm-core
27
- requirement: &14445360 !ruby/object:Gem::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: *14445360
35
+ version_requirements: *13409180
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &14444580 !ruby/object:Gem::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: *14444580
46
+ version_requirements: *13408800
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &14443860 !ruby/object:Gem::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: *14443860
57
+ version_requirements: *13408340
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: dm-pager
60
- requirement: &14431500 !ruby/object:Gem::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: *14431500
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