mwmitchell-rsolr-ext 0.7.2 → 0.7.3

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.rdoc CHANGED
@@ -2,7 +2,7 @@
2
2
  A set of helper methods/modules to assist in building Solr queries and handling responses when using the RSolr library.
3
3
 
4
4
  ==Request Example
5
- solr_params = RSolr::Ext.map_params(
5
+ solr_params = {
6
6
  :page=>2,
7
7
  :per_page=>10,
8
8
  :phrases=>{:name=>'This is a phrase'},
@@ -10,69 +10,39 @@ A set of helper methods/modules to assist in building Solr queries and handling
10
10
  :phrase_filters=>{:manu=>['Apple']},
11
11
  :queries=>'ipod',
12
12
  :facets=>{:fields=>['cat', 'blah']}
13
- )
13
+ }
14
14
 
15
- rsolr = RSolr.connect
15
+ rsolr = RSolr::Ext.connect
16
16
 
17
17
  response = rsolr.select(solr_params)
18
18
 
19
19
  ==Response Example
20
- rsolr = RSolr.connect
20
+ rsolr = RSolr::Ext.connect
21
21
 
22
- raw_response = rsolr.select(:q=>'*:*)
23
- r = RSolr::Ext::wrap_response(raw_response)
22
+ response = rsolr.select(:q=>'*:*)
24
23
 
25
- r.ok?
26
- r.params
27
- r.docs
28
- r.docs.previous_page
29
- r.docs.next_page
30
- r.facets
24
+ response.ok?
25
+ response.params
26
+ response.docs
27
+ response.docs.previous_page
28
+ response.docs.next_page
29
+ response.facets
31
30
 
32
31
  You can access values in the response hash using symbols or strings.
33
32
 
34
33
  ===Doc Pagination
35
- After creating a RSolr::Ext::Response object, pass-in the response.docs to the will_paginate view helper:
36
- rsolr = RSolr.connect
37
- raw_response = rsolr.select(:q=>'*:*)
38
- @response = RSolr::Ext.wrap_response(raw_response)
39
- # in view:
40
- <%= will_paginate @response.docs %>
41
-
42
- ==The Findable Module
43
-
44
- You can get a modified RSolr.connect object by calling RSolr::Ext.connect.
45
-
46
- The object returned is an RSolr::Connection::Adapter (Direct or HTTP) with additional methods attached, most notably #find, which comes from the RSolr::Ext::Findable module.
47
-
48
- The #find method provides a convenient way to search solr. Here are some examples:
49
-
50
- solr = RSolr::Ext.connect
51
-
52
- # q=jefferson - returns all docs
53
- all_jefferson_docs = solr.find 'jefferson'
54
-
55
- # q=jefferson&rows=1 -- first doc only
56
- a_single_jefferson_doc = solr.find :first, 'jefferson'
57
-
58
- # q=jefferson&fq=type:"book" - all docs
59
- books_about_jefferson = solr.find 'jefferson', :phrase_filters=>{:type=>'book'}
60
-
61
- # q=something -- the entire response
62
- solr_response = solr.find {:q=>'something'}, :include_response=>true
34
+ If you wanna paginate, just throw the collection into the WillPaginate view helper.
35
+ <%= will_paginate response.docs %>
63
36
 
64
37
  ===The Doc Module
65
38
  You can create your own "models" using RSolr::Ext::Doc
39
+
66
40
  class Book
67
41
  include RSolr::Ext::Doc
68
- @default_params = {:fq=>'object_type:"book"', :rows=>10}
69
-
70
42
  def self.find_by_author(author)
71
- find(:phrase_filters=>{:author=>author})
43
+ find(:fq=>'object_type:"book"', :rows=>10, :phrase_filters=>{:author=>author})
72
44
  end
73
45
  end
74
46
 
75
47
  all_books = Book.find('*:*')
76
48
  hawk_books = Book.find_by_author('hawk')
77
-
78
- If you wanna paginate, just throw the collection into the WillPaginate view helper.
@@ -1,6 +1,6 @@
1
1
  module RSolr::Ext::Response::Docs
2
2
 
3
- module Accessable
3
+ module Accessible
4
4
 
5
5
  # Helper method to check if value/multi-values exist for a given key.
6
6
  # The value can be a string, or a RegExp
@@ -83,7 +83,9 @@ module RSolr::Ext::Response::Docs
83
83
  def self.extended(base)
84
84
  d = base['response']['docs']
85
85
  d.extend Pageable
86
- d.each{|item|item.extend Accessable}
86
+ d.each do |item|
87
+ item.extend Accessible
88
+ end
87
89
  d.per_page = base['responseHeader']['params']['rows'].to_s.to_i
88
90
  d.start = base['response']['start'].to_s.to_i
89
91
  d.total = base['response']['numFound'].to_s.to_i
@@ -2,6 +2,7 @@ module RSolr::Ext::Response
2
2
 
3
3
  autoload :Facets, 'rsolr-ext/response/facets'
4
4
  autoload :Docs, 'rsolr-ext/response/docs'
5
+ autoload :Spelling, 'rsolr-ext/response/spelling'
5
6
 
6
7
  class Base < Mash
7
8
 
@@ -26,10 +27,16 @@ module RSolr::Ext::Response
26
27
  super(*args)
27
28
  extend Docs
28
29
  extend Facets
30
+ extend Spelling
29
31
  end
30
32
 
31
33
  def response
32
- self['response']
34
+ self[:response]
35
+ end
36
+
37
+ # short cut to response['numFound']
38
+ def total
39
+ response[:numFound]
33
40
  end
34
41
 
35
42
  end
data/lib/rsolr-ext.rb CHANGED
@@ -23,7 +23,7 @@ module RSolr
23
23
 
24
24
  module Ext
25
25
 
26
- VERSION = '0.7.2'
26
+ VERSION = '0.7.3'
27
27
 
28
28
  autoload :Request, 'rsolr-ext/request.rb'
29
29
  autoload :Response, 'rsolr-ext/response.rb'
data/rsolr-ext.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rsolr-ext"
3
- s.version = "0.7.2"
4
- s.date = "2009-05-17"
3
+ s.version = "0.7.3"
4
+ s.date = "2009-05-27"
5
5
  s.summary = "An extension lib for RSolr"
6
6
  s.email = "goodieboy@gmail.com"
7
7
  s.homepage = "http://github.com/mwmitchell/rsolr_ext"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mwmitchell-rsolr-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Mitchell
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-17 00:00:00 -07:00
12
+ date: 2009-05-27 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15