rsolr-ext 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -11,7 +11,7 @@ A set of helper methods/modules to assist in building Solr queries and handling
11
11
  ==Requests
12
12
  To use the RSolr::Ext connection instead of the normal RSolr connection just require 'rsolr-ext':
13
13
  require 'rsolr-ext'
14
- solr = RSolr.connect
14
+ solr = RSolr::Ext.connect
15
15
 
16
16
  RSolr::Ext adds a #find and a #luke method to the connection object.
17
17
 
@@ -73,7 +73,7 @@ The #find method listens for certain keys. All other keys are ignored, allowing
73
73
 
74
74
  ==Request Example
75
75
  require 'rsolr-ext'
76
- solr = RSolr.connect
76
+ solr = RSolr::Ext.connect
77
77
  solr_params = {
78
78
  :page=>2,
79
79
  :per_page=>10,
@@ -84,13 +84,13 @@ The #find method listens for certain keys. All other keys are ignored, allowing
84
84
  :facets=>{:fields=>['cat', 'blah']},
85
85
  :echoParams => 'EXPLICIT'
86
86
  }
87
- response = rsolr.find solr_params
87
+ response = rsolr.find solr_params, :method => :post
88
88
 
89
89
  ==Responses
90
90
  RSolr::Ext decorates the normal output hash from RSolr and adds some helpful methods.
91
91
 
92
92
  require 'rsolr-ext'
93
- solr = RSolr.connect
93
+ solr = RSolr::Ext.connect
94
94
 
95
95
  response = solr.find :q=>'*:*'
96
96
 
@@ -109,8 +109,8 @@ RSolr::Ext decorates the normal output hash from RSolr and adds some helpful met
109
109
  You can access values in the response hash using symbols or strings.
110
110
 
111
111
  ===Documents/Pagination
112
- If you wanna paginate, just throw the collection into the WillPaginate view helper.
113
- <%= will_paginate response.docs %>
112
+ If you wanna paginate the documents:
113
+ <%= will_paginate response.docs.will_paginate %>
114
114
 
115
115
  ==The "Model" Module
116
116
  You can create your own <read-only> "models" using RSolr::Ext::Model
data/Rakefile CHANGED
@@ -9,9 +9,9 @@ begin
9
9
  gem.description = %Q{A query/response extension lib for RSolr}
10
10
  gem.email = "goodieboy@gmail.com"
11
11
  gem.homepage = "http://github.com/mwmitchell/rsolr-ext"
12
- gem.authors = ["Matt Mitchell"]
12
+ gem.authors = ["Matt Mitchell", "James Davidson", "Chris Beer", "Jason Ronallo", "Eric Lindvall", "Andreas Kemkes"]
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
- gem.add_dependency "rsolr", ">= 1.0.0"
14
+ gem.add_dependency "rsolr", ">= 1.0.1"
15
15
 
16
16
  gem.files = FileList['lib/**/*.rb', 'LICENSE', 'README.rdoc', 'VERSION']
17
17
  gem.test_files = ['spec/*', 'Rakefile']
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -1,26 +1,32 @@
1
1
  module RSolr::Ext::Client
2
-
2
+
3
3
  # TWO modes of arguments:
4
4
  #
5
5
  # <request-handler-path>, <solr-params-hash>
6
6
  # OR
7
7
  # <solr-params-hash>
8
8
  #
9
- # The default request-handler-path is select
9
+ # The default request-handler-path is "select"
10
10
  #
11
11
  # If a hash is used for solr params, all of the normal RSolr::Ext::Request
12
12
  # mappings are available (everything else gets passed to solr).
13
13
  # Returns a new RSolr::Ext::Response::Base object.
14
14
  def find *args
15
- # remove the handler arg - the first, if it is a string OR set default
16
- path = args.first.is_a?(String) ? args.shift : 'select'
17
- # remove the params - the first, if it is a Hash OR set default
18
- params = args.first.kind_of?(Hash) ? args.shift : {}
15
+ path, params, opts = rsolr_request_arguments_for(*args)
16
+ path ||= "select"
19
17
  # send path, map params and send the rest of the args along
20
- response = self.send_and_receive path, { :params => RSolr::Ext::Request.map(params) }
18
+ response = self.send_and_receive path, opts.merge({ :params => RSolr::Ext::Request.map(params) })
21
19
  RSolr::Ext::Response::Base.new(response, path, params)
22
20
  end
23
21
 
22
+ # A simple helper method to return an integer value for the count of
23
+ # resulting rows for the specified query.
24
+ def count *args
25
+ path, params, opts = rsolr_request_arguments_for(*args)
26
+ path ||= "select"
27
+ find(path, params.merge(:rows => 0), opts).total
28
+ end
29
+
24
30
  # TWO modes of arguments:
25
31
  #
26
32
  # <request-handler-path>, <solr-params-hash>
@@ -32,17 +38,17 @@ module RSolr::Ext::Client
32
38
  #
33
39
  # Returns a new Mash object.
34
40
  def luke *args
35
- path = args.first.is_a?(String) ? args.shift : 'admin/luke'
36
- params = args.pop || {}
41
+ path, params, opts = rsolr_request_arguments_for(*args)
42
+ path ||= "admin/luke"
37
43
  params['numTerms'] ||= 0
38
- self.get(path, params).to_mash
44
+ self.get(path, opts.merge(:params => params)).to_mash
39
45
  end
40
46
 
41
47
  # sends request to /admin/ping
42
48
  def ping *args
43
- path = args.first.is_a?(String) ? args.shift : 'admin/ping'
44
- params = args.pop || {:wt => :ruby}
45
- self.get(path, params).to_mash
49
+ path, params, opts = rsolr_request_arguments_for(*args)
50
+ path ||= "admin/ping"
51
+ self.get(path, opts.merge(:params => params)).to_mash
46
52
  end
47
53
 
48
54
  # Ping the server and make sure it is alright
@@ -60,4 +66,19 @@ module RSolr::Ext::Client
60
66
  ping['status'] == 'OK'
61
67
  end
62
68
 
69
+ private
70
+
71
+ # Helper method to return the parameters needed for requesting
72
+ # from Solr.
73
+ def rsolr_request_arguments_for *args
74
+ [].tap do |arr|
75
+ # remove the handler arg - the first, if it is a string OR set default
76
+ arr << (args.first.is_a?(String) ? args.shift : nil)
77
+ # remove the params - the first, if it is a Hash OR set default
78
+ arr << (args.first.kind_of?(Hash) ? args.shift : {})
79
+ # everything that isn't params is opts
80
+ arr << (args.first.kind_of?(Hash) ? args.shift : {})
81
+ end
82
+ end
83
+
63
84
  end
@@ -1,5 +1,30 @@
1
1
  module RSolr::Ext::Response::Docs
2
2
 
3
+ # NOTE: This might move/change in the next major release of RSolr::Ext
4
+ module WillPaginateExt
5
+ class MissingLibError < RuntimeError
6
+ def to_s; "WillPaginate is required" end
7
+ end
8
+ def will_paginate
9
+ WillPaginate::Collection.create(self.current_page, self.per_page, self.total) do |pager|
10
+ pager.replace(self)
11
+ end
12
+ rescue NameError
13
+ raise MissingLibError.new
14
+ end
15
+ end
16
+
17
+ def self.extended(base)
18
+ d = base['response']['docs']
19
+ # TODO: could we do this lazily (Enumerable etc.)
20
+ d.each{|doc| doc.extend RSolr::Ext::Doc }
21
+ d.extend Pageable
22
+ d.per_page = [base.rows, 1].max
23
+ d.start = base.start
24
+ d.total = base.total
25
+ d.extend WillPaginateExt
26
+ end
27
+
3
28
  module Pageable
4
29
 
5
30
  attr_accessor :start, :per_page, :total
@@ -40,17 +65,11 @@ module RSolr::Ext::Response::Docs
40
65
 
41
66
  end
42
67
 
43
- def self.extended(base)
44
- d = base['response']['docs']
45
- d.each{|doc| doc.extend RSolr::Ext::Doc }
46
- d.extend Pageable
47
- d.per_page = base.rows
48
- d.start = base.start
49
- d.total = base.total
50
- end
51
-
52
68
  def docs
53
- response['docs']
69
+ @docs ||= begin
70
+ warn "DEPRECATION WARNING: The custom pagination codebase in RSolr::Ext will no longer be supported. Use response.docs.will_paginate instead."
71
+ response['docs']
72
+ end
54
73
  end
55
74
 
56
75
  end
@@ -25,8 +25,8 @@ module RSolr::Ext::Response::Facets
25
25
  @facets ||= (
26
26
  facet_fields.map do |(facet_field_name,values_and_hits)|
27
27
  items = []
28
- (values_and_hits.size/2).times do |index|
29
- items << FacetItem.new(values_and_hits[index*2], values_and_hits[index*2+1])
28
+ values_and_hits.each_slice(2) do |k,v|
29
+ items << FacetItem.new(k, v)
30
30
  end
31
31
  FacetField.new(facet_field_name, items)
32
32
  end
@@ -52,10 +52,6 @@ module RSolr::Ext::Response
52
52
  response[:numFound].to_s.to_i
53
53
  end
54
54
 
55
- def total
56
- response[:numFound].to_s.to_i
57
- end
58
-
59
55
  def start
60
56
  response[:start].to_s.to_i
61
57
  end
data/lib/rsolr-ext.rb CHANGED
@@ -1,5 +1,3 @@
1
- # add this directory to the load path if it hasn't already been added
2
-
3
1
  require File.join(File.dirname(__FILE__), 'mash') unless defined?(Mash)
4
2
 
5
3
  unless Hash.respond_to?(:to_mash)
@@ -10,6 +8,8 @@ unless Hash.respond_to?(:to_mash)
10
8
  end
11
9
  end
12
10
 
11
+ $: << File.dirname(__FILE__) unless $:.include?(File.dirname(__FILE__))
12
+
13
13
  require 'rubygems'
14
14
  require 'rsolr'
15
15
 
@@ -29,11 +29,10 @@ module RSolr::Ext
29
29
 
30
30
  # modify the RSolr::Client (provides #find and #luke methods)
31
31
  RSolr::Client.class_eval do
32
+ warn "DEPRECATION WARNING: Future versions of RSolr::Ext will require initialization via RSolr::Ext.connect."
32
33
  include RSolr::Ext::Client
33
34
  end
34
35
 
35
- # this is for backward compatibility: RSolr::Ext.connect
36
- # recommended way is to just use RSolr.connect
37
36
  def self.connect *args, &blk
38
37
  RSolr.connect *args, &blk
39
38
  end
@@ -33,6 +33,20 @@ describe RSolr::Ext do
33
33
  response.raw[:path].should match(/select/)
34
34
  end
35
35
 
36
+ it "should pass on the opts hash to the send_and_receive method" do
37
+ c = client
38
+ expected_response = { 'response' => { 'docs' => [] }, 'responseHeader' => {}}
39
+ # ok this is hacky... the raw method needs to go into a mixin dude
40
+ def expected_response.raw
41
+ {:path => 'select'}
42
+ end
43
+
44
+ c.should_receive(:send_and_receive).
45
+ with('select', {:params => { :q => '*:*' }, :method => :post}).
46
+ and_return(expected_response)
47
+ response = c.find 'select', { :q => '*:*'}, { :method => :post }
48
+ end
49
+
36
50
  it 'should be ok' do
37
51
  c = client
38
52
  c.should_receive(:send_and_receive).
@@ -46,7 +60,7 @@ describe RSolr::Ext do
46
60
  it 'should call the #luke method' do
47
61
  c = client
48
62
  c.should_receive(:get).
49
- with('admin/luke', {"numTerms"=>0}).
63
+ with('admin/luke', :params => {"numTerms"=>0}).
50
64
  and_return({"fields"=>nil, "index"=>nil, "info" => nil})
51
65
  info = c.luke
52
66
  info.should be_a(Mash)
@@ -57,8 +71,8 @@ describe RSolr::Ext do
57
71
 
58
72
  it 'should forward #ping? calls to the connection' do
59
73
  client.should_receive(:get).
60
- with('admin/ping', :wt => :ruby ).
61
- and_return( :params => { :wt => :ruby },
74
+ with('admin/ping', :params => {} ).
75
+ and_return( :params => {},
62
76
  :status_code => 200,
63
77
  :body => "{'responseHeader'=>{'status'=>0,'QTime'=>44,'params'=>{'echoParams'=>'all','echoParams'=>'all','q'=>'solrpingquery','qt'=>'standard','wt'=>'ruby'}},'status'=>'OK'}" )
64
78
  client.ping?
@@ -66,12 +80,55 @@ describe RSolr::Ext do
66
80
 
67
81
  it 'should raise an error if the ping service is not available' do
68
82
  client.should_receive(:get).
69
- with('admin/ping', :wt => :ruby ).
83
+ with('admin/ping', {:params => {}} ).
70
84
  # the first part of the what the message would really be
71
85
  and_raise( RuntimeError.new("Solr Response: pingQuery_not_configured_consider_registering_PingRequestHandler_with_the_name_adminping_instead__") )
72
86
  lambda { client.ping? }.should raise_error( RuntimeError )
73
87
  end
74
88
 
89
+ describe "#count" do
90
+ it "should return the count of resulting rows" do
91
+ c = client
92
+ c.should_receive(:send_and_receive).
93
+ with('select', { :params => { :q => '*:*', :rows => 0 }}).
94
+ and_return(eval(mock_query_response))
95
+
96
+ response = c.count :q => '*:*'
97
+ response.should == 26
98
+ end
99
+
100
+ it "should not return any row data" do
101
+ c = client
102
+ c.should_receive(:send_and_receive).
103
+ with('select', { :params => { :q => '*:*', :rows => 0 }}).
104
+ and_return(eval(mock_query_response_for_count))
105
+
106
+ c.count :q => '*:*'
107
+ end
108
+
109
+ end
110
+
111
+ describe "#rsolr_request_arguments_for" do
112
+ it "should split out the method" do
113
+ c = client
114
+ c.send(:rsolr_request_arguments_for, 'foo', {}, {}).first.should == 'foo'
115
+ end
116
+
117
+ it "should return a nil path when not given" do
118
+ c = client
119
+ c.send(:rsolr_request_arguments_for, {}, {})[0].should == nil
120
+ end
121
+
122
+ it "should split out the params" do
123
+ c = client
124
+ c.send(:rsolr_request_arguments_for, { :q => "foo" }, {})[1].should == { :q => "foo" }
125
+ end
126
+
127
+ it "should split out the opts" do
128
+ c = client
129
+ c.send(:rsolr_request_arguments_for, {}, {:method => :foo})[2].should == { :method => :foo }
130
+ end
131
+ end
75
132
  end
76
133
 
77
134
  context 'requests' do
@@ -163,6 +220,8 @@ describe RSolr::Ext do
163
220
  r.params[:echoParams].should == 'EXPLICIT'
164
221
  r.docs.previous_page.should == 1
165
222
  r.docs.next_page.should == 2
223
+ r.docs.has_previous?.should == false
224
+ r.docs.has_next?.should == true
166
225
  #
167
226
  r.should be_a(RSolr::Ext::Response::Docs)
168
227
  r.should be_a(RSolr::Ext::Response::Facets)
@@ -269,8 +328,34 @@ describe RSolr::Ext do
269
328
  r = RSolr::Ext::Response::Base.new(raw_response, '/catalog', {})
270
329
  r.spelling.collation.should == 'dell ultrasharp'
271
330
  end
331
+
332
+ ###############################
333
+
334
+ context "docs.will_paginate" do
335
+
336
+ it 'will raise a RSolr::Ext::Response::Docs::WillPaginateExt::MissingLibError if WillPaginate is not defined' do
337
+ r = create_response
338
+ r.docs.should respond_to(:will_paginate)
339
+ lambda{
340
+ r.docs.will_paginate
341
+ }.should(raise_error(
342
+ RSolr::Ext::Response::Docs::WillPaginateExt::MissingLibError,
343
+ "WillPaginate is required"))
344
+ end
345
+
346
+ it 'will work, and return a WillPaginate::Collectionified doc array' do
347
+ # this is one funky part about dynamic dependencies...
348
+ require "will_paginate"
349
+ r = create_response
350
+ original_docs = r.docs
351
+ r.docs.should_not be_a(WillPaginate::Collection)
352
+ r.docs.should respond_to(:will_paginate)
353
+ r.docs.will_paginate.should be_a(WillPaginate::Collection)
354
+ r.docs.should be(original_docs)
355
+ end
356
+
357
+ end
272
358
 
273
359
  end
274
360
 
275
- end
276
-
361
+ end
data/spec/spec_helper.rb CHANGED
@@ -10,6 +10,10 @@ Spec::Runner.configure do |config|
10
10
  %({'responseHeader'=>{'status'=>0,'QTime'=>5,'params'=>{'facet.limit'=>'10','wt'=>'ruby','rows'=>'11','facet'=>'true','facet.field'=>['cat','manu'],'echoParams'=>'EXPLICIT','q'=>'*:*','facet.sort'=>'true'}},'response'=>{'numFound'=>26,'start'=>0,'docs'=>[{'id'=>'SP2514N','inStock'=>true,'manu'=>'Samsung Electronics Co. Ltd.','name'=>'Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133','popularity'=>6,'price'=>92.0,'sku'=>'SP2514N','timestamp'=>'2009-03-20T14:42:49.795Z','cat'=>['electronics','hard drive'],'spell'=>['Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133'],'features'=>['7200RPM, 8MB cache, IDE Ultra ATA-133','NoiseGuard, SilentSeek technology, Fluid Dynamic Bearing (FDB) motor']},{'id'=>'6H500F0','inStock'=>true,'manu'=>'Maxtor Corp.','name'=>'Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300','popularity'=>6,'price'=>350.0,'sku'=>'6H500F0','timestamp'=>'2009-03-20T14:42:49.877Z','cat'=>['electronics','hard drive'],'spell'=>['Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300'],'features'=>['SATA 3.0Gb/s, NCQ','8.5ms seek','16MB cache']},{'id'=>'F8V7067-APL-KIT','inStock'=>false,'manu'=>'Belkin','name'=>'Belkin Mobile Power Cord for iPod w/ Dock','popularity'=>1,'price'=>19.95,'sku'=>'F8V7067-APL-KIT','timestamp'=>'2009-03-20T14:42:49.937Z','weight'=>4.0,'cat'=>['electronics','connector'],'spell'=>['Belkin Mobile Power Cord for iPod w/ Dock'],'features'=>['car power adapter, white']},{'id'=>'IW-02','inStock'=>false,'manu'=>'Belkin','name'=>'iPod & iPod Mini USB 2.0 Cable','popularity'=>1,'price'=>11.5,'sku'=>'IW-02','timestamp'=>'2009-03-20T14:42:49.944Z','weight'=>2.0,'cat'=>['electronics','connector'],'spell'=>['iPod & iPod Mini USB 2.0 Cable'],'features'=>['car power adapter for iPod, white']},{'id'=>'MA147LL/A','inStock'=>true,'includes'=>'earbud headphones, USB cable','manu'=>'Apple Computer Inc.','name'=>'Apple 60 GB iPod with Video Playback Black','popularity'=>10,'price'=>399.0,'sku'=>'MA147LL/A','timestamp'=>'2009-03-20T14:42:49.962Z','weight'=>5.5,'cat'=>['electronics','music'],'spell'=>['Apple 60 GB iPod with Video Playback Black'],'features'=>['iTunes, Podcasts, Audiobooks','Stores up to 15,000 songs, 25,000 photos, or 150 hours of video','2.5-inch, 320x240 color TFT LCD display with LED backlight','Up to 20 hours of battery life','Plays AAC, MP3, WAV, AIFF, Audible, Apple Lossless, H.264 video','Notes, Calendar, Phone book, Hold button, Date display, Photo wallet, Built-in games, JPEG photo playback, Upgradeable firmware, USB 2.0 compatibility, Playback speed control, Rechargeable capability, Battery level indication']},{'id'=>'TWINX2048-3200PRO','inStock'=>true,'manu'=>'Corsair Microsystems Inc.','name'=>'CORSAIR XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) Dual Channel Kit System Memory - Retail','popularity'=>5,'price'=>185.0,'sku'=>'TWINX2048-3200PRO','timestamp'=>'2009-03-20T14:42:49.99Z','cat'=>['electronics','memory'],'spell'=>['CORSAIR XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) Dual Channel Kit System Memory - Retail'],'features'=>['CAS latency 2, 2-3-3-6 timing, 2.75v, unbuffered, heat-spreader']},{'id'=>'VS1GB400C3','inStock'=>true,'manu'=>'Corsair Microsystems Inc.','name'=>'CORSAIR ValueSelect 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - Retail','popularity'=>7,'price'=>74.99,'sku'=>'VS1GB400C3','timestamp'=>'2009-03-20T14:42:50Z','cat'=>['electronics','memory'],'spell'=>['CORSAIR ValueSelect 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - Retail']},{'id'=>'VDBDB1A16','inStock'=>true,'manu'=>'A-DATA Technology Inc.','name'=>'A-DATA V-Series 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - OEM','popularity'=>5,'sku'=>'VDBDB1A16','timestamp'=>'2009-03-20T14:42:50.004Z','cat'=>['electronics','memory'],'spell'=>['A-DATA V-Series 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - OEM'],'features'=>['CAS latency 3, 2.7v']},{'id'=>'3007WFP','inStock'=>true,'includes'=>'USB cable','manu'=>'Dell, Inc.','name'=>'Dell Widescreen UltraSharp 3007WFP','popularity'=>6,'price'=>2199.0,'sku'=>'3007WFP','timestamp'=>'2009-03-20T14:42:50.017Z','weight'=>401.6,'cat'=>['electronics','monitor'],'spell'=>['Dell Widescreen UltraSharp 3007WFP'],'features'=>['30" TFT active matrix LCD, 2560 x 1600, .25mm dot pitch, 700:1 contrast']},{'id'=>'VA902B','inStock'=>true,'manu'=>'ViewSonic Corp.','name'=>'ViewSonic VA902B - flat panel display - TFT - 19"','popularity'=>6,'price'=>279.95,'sku'=>'VA902B','timestamp'=>'2009-03-20T14:42:50.034Z','weight'=>190.4,'cat'=>['electronics','monitor'],'spell'=>['ViewSonic VA902B - flat panel display - TFT - 19"'],'features'=>['19" TFT active matrix LCD, 8ms response time, 1280 x 1024 native resolution']},{'id'=>'0579B002','inStock'=>true,'manu'=>'Canon Inc.','name'=>'Canon PIXMA MP500 All-In-One Photo Printer','popularity'=>6,'price'=>179.99,'sku'=>'0579B002','timestamp'=>'2009-03-20T14:42:50.062Z','weight'=>352.0,'cat'=>['electronics','multifunction printer','printer','scanner','copier'],'spell'=>['Canon PIXMA MP500 All-In-One Photo Printer'],'features'=>['Multifunction ink-jet color photo printer','Flatbed scanner, optical scan resolution of 1,200 x 2,400 dpi','2.5" color LCD preview screen','Duplex Copying','Printing speed up to 29ppm black, 19ppm color','Hi-Speed USB','memory card: CompactFlash, Micro Drive, SmartMedia, Memory Stick, Memory Stick Pro, SD Card, and MultiMediaCard']}]},'facet_counts'=>{'facet_queries'=>{},'facet_fields'=>{'cat'=>['electronics',14,'memory',3,'card',2,'connector',2,'drive',2,'graphics',2,'hard',2,'monitor',2,'search',2,'software',2],'manu'=>['inc',8,'apach',2,'belkin',2,'canon',2,'comput',2,'corp',2,'corsair',2,'foundat',2,'microsystem',2,'softwar',2]},'facet_dates'=>{}}})
11
11
  end
12
12
 
13
+ def mock_query_response_for_count
14
+ %({'responseHeader'=>{'status'=>0,'QTime'=>5,'params'=>{'facet.limit'=>'10','wt'=>'ruby','rows'=>'11','facet'=>'true','facet.field'=>['cat','manu'],'echoParams'=>'EXPLICIT','q'=>'*:*','facet.sort'=>'true'}},'response'=>{'numFound'=>26,'start'=>0,'docs'=>[]},'facet_counts'=>{'facet_queries'=>{},'facet_fields'=>{'cat'=>['electronics',14,'memory',3,'card',2,'connector',2,'drive',2,'graphics',2,'hard',2,'monitor',2,'search',2,'software',2],'manu'=>['inc',8,'apach',2,'belkin',2,'canon',2,'comput',2,'corp',2,'corsair',2,'foundat',2,'microsystem',2,'softwar',2]},'facet_dates'=>{}}})
15
+ end
16
+
13
17
  # These spellcheck responses are all Solr 1.4 responses
14
18
  def mock_response_with_spellcheck
15
19
  %|{'responseHeader'=>{'status'=>0,'QTime'=>9,'params'=>{'spellcheck'=>'true','spellcheck.collate'=>'true','wt'=>'ruby','q'=>'hell ultrashar'}},'response'=>{'numFound'=>0,'start'=>0,'docs'=>[]},'spellcheck'=>{'suggestions'=>['hell',{'numFound'=>1,'startOffset'=>0,'endOffset'=>4,'suggestion'=>['dell']},'ultrashar',{'numFound'=>1,'startOffset'=>5,'endOffset'=>14,'suggestion'=>['ultrasharp']},'collation','dell ultrasharp']}}|
metadata CHANGED
@@ -1,21 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsolr-ext
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Mitchell
14
+ - James Davidson
15
+ - Chris Beer
16
+ - Jason Ronallo
17
+ - Eric Lindvall
18
+ - Andreas Kemkes
14
19
  autorequire:
15
20
  bindir: bin
16
21
  cert_chain: []
17
22
 
18
- date: 2011-03-01 00:00:00 -05:00
23
+ date: 2011-05-26 00:00:00 -04:00
19
24
  default_executable:
20
25
  dependencies:
21
26
  - !ruby/object:Gem::Dependency
@@ -42,12 +47,12 @@ dependencies:
42
47
  requirements:
43
48
  - - ">="
44
49
  - !ruby/object:Gem::Version
45
- hash: 23
50
+ hash: 21
46
51
  segments:
47
52
  - 1
48
53
  - 0
49
- - 0
50
- version: 1.0.0
54
+ - 1
55
+ version: 1.0.1
51
56
  type: :runtime
52
57
  version_requirements: *id002
53
58
  description: A query/response extension lib for RSolr