mwmitchell-rsolr-ext 0.5.7 → 0.5.8
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 +6 -4
- data/lib/rsolr-ext.rb +1 -1
- data/lib/rsolr-ext/mapable.rb +1 -1
- data/lib/rsolr-ext/request.rb +2 -2
- data/rsolr-ext.gemspec +1 -1
- data/test/request_test.rb +10 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
=RSolr::Ext
|
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
|
+
NOTE: The API for RSolr::Ext is pre 1.0. Things are be changing!
|
5
|
+
|
4
6
|
==Request Example
|
5
7
|
std = RSolr::Ext::Request::Standard.new
|
6
8
|
|
@@ -23,9 +25,9 @@ A set of helper methods/modules to assist in building Solr queries and handling
|
|
23
25
|
raw_response = rsolr.select(:q=>'*:*)
|
24
26
|
r = RSolr::Ext::Response::Standard.new(raw_response)
|
25
27
|
|
26
|
-
r.
|
27
|
-
r.response
|
28
|
-
r.response
|
28
|
+
r.header[:params]
|
29
|
+
r.response[:docs]
|
30
|
+
r.response[:docs].previous_page
|
29
31
|
|
30
32
|
===Doc Pagination
|
31
33
|
After creating a RSolr::Ext::Response object, pass-in the response.docs to the will_paginate view helper:
|
@@ -33,4 +35,4 @@ After creating a RSolr::Ext::Response object, pass-in the response.docs to the w
|
|
33
35
|
raw_response = rsolr.select(:q=>'*:*)
|
34
36
|
@response = RSolr::Ext::Response::Standard.new(raw_response)
|
35
37
|
# in view:
|
36
|
-
<%= will_paginate @response.response
|
38
|
+
<%= will_paginate @response.response[:docs] %>
|
data/lib/rsolr-ext.rb
CHANGED
data/lib/rsolr-ext/mapable.rb
CHANGED
@@ -38,7 +38,7 @@ module RSolr::Ext::Mapable
|
|
38
38
|
def append_to_param(existing_value, new_value, auto_join=true)
|
39
39
|
values = [existing_value, new_value]
|
40
40
|
values.delete_if{|v|v.nil?}
|
41
|
-
auto_join ? values.join(' ') : values
|
41
|
+
auto_join ? values.join(' ') : values.flatten
|
42
42
|
end
|
43
43
|
|
44
44
|
end
|
data/lib/rsolr-ext/request.rb
CHANGED
@@ -32,11 +32,11 @@ module RSolr::Ext::Request
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def map_filters(value,output)
|
35
|
-
output[:fq] = append_to_param(output[:fq], build_query(value))
|
35
|
+
output[:fq] = append_to_param(output[:fq], build_query(value), false)
|
36
36
|
end
|
37
37
|
|
38
38
|
def map_phrase_filters(value,output)
|
39
|
-
output[:fq] = append_to_param(output[:fq], build_query(value, true))
|
39
|
+
output[:fq] = append_to_param(output[:fq], build_query(value, true), false)
|
40
40
|
end
|
41
41
|
|
42
42
|
def map_facets(value,output)
|
data/rsolr-ext.gemspec
CHANGED
data/test/request_test.rb
CHANGED
@@ -14,7 +14,7 @@ class RSolrExtRequestTest < Test::Unit::TestCase
|
|
14
14
|
:q=>'ipod',
|
15
15
|
:facets=>{:fields=>['cat', 'blah']}
|
16
16
|
)
|
17
|
-
assert_equal "test price:[1 TO 10] manu:\"Apple\"", solr_params[:fq]
|
17
|
+
assert_equal ["test", "price:[1 TO 10]", "manu:\"Apple\""], solr_params[:fq]
|
18
18
|
assert_equal 10, solr_params[:start]
|
19
19
|
assert_equal 10, solr_params[:rows]
|
20
20
|
assert_equal "ipod name:\"This is a phrase\"", solr_params[:q]
|
@@ -22,4 +22,13 @@ class RSolrExtRequestTest < Test::Unit::TestCase
|
|
22
22
|
assert_equal true, solr_params[:facet]
|
23
23
|
end
|
24
24
|
|
25
|
+
test 'fq param using the phrase_filters mapping' do
|
26
|
+
std = RSolr::Ext::Request::Standard.new
|
27
|
+
solr_params = std.map(
|
28
|
+
:phrase_filters=>[{:manu=>'Apple'}, {:color=>'red'}]
|
29
|
+
)
|
30
|
+
assert solr_params[:fq].is_a?(Array)
|
31
|
+
assert solr_params[:fq].first.is_a?(String)
|
32
|
+
end
|
33
|
+
|
25
34
|
end
|