mwmitchell-rsolr 0.6.7 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +9 -0
- data/README.rdoc +1 -3
- data/lib/rsolr/connection/base.rb +16 -0
- data/lib/rsolr.rb +1 -1
- data/test/connection/test_methods.rb +9 -0
- metadata +1 -1
data/CHANGES.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
0.6.8 - January 28, 2009
|
2
|
+
New method added to RSolr::Connection::Base - #find_values_for_facet
|
3
|
+
This method searches for facet values only, and sets the :rows param to 0
|
4
|
+
- returns an RSolr::Response::Query::Base instance
|
5
|
+
Example:
|
6
|
+
search_params[:facets][:offset]=0
|
7
|
+
search_params[:facets][:limit]=5
|
8
|
+
response = solr.search_facet_by_name(:language_facet, search_params)
|
9
|
+
|
1
10
|
0.6.7 - January 27, 2009
|
2
11
|
The Symbol extension in core_ext.rb was cause for some REALLY painful debuging - so I removed it :(
|
3
12
|
This means no more :q.alt or :facet.field until RSolr gets a really nice query-builder module happening.
|
data/README.rdoc
CHANGED
@@ -40,11 +40,9 @@ Once you have a connection, you can execute queries, updates etc..
|
|
40
40
|
=== Querying
|
41
41
|
Use the #query method to send requests to Solr as-is (no param mapping)
|
42
42
|
Use the #search method to take advantage of some of the param mapping (currently only :page and :per_page)
|
43
|
-
response = solr.query(:q=>'washington', :facet=>true,
|
43
|
+
response = solr.query(:q=>'washington', :facet=>true, 'facet.limit'=>-1, 'facet.field'=>'cat', 'facet.field'=>'inStock')
|
44
44
|
response = solr.find_by_id(1)
|
45
45
|
|
46
|
-
Thanks to a little Ruby magic, we can chain symbols to create Solr "dot" syntax: :facet.field=>'cat'
|
47
|
-
|
48
46
|
==== Search Params
|
49
47
|
The #search method can accept the following params:
|
50
48
|
===== When :qt is :standard
|
@@ -53,6 +53,22 @@ class RSolr::Connection::Base
|
|
53
53
|
query(mapper.map(&blk))
|
54
54
|
end
|
55
55
|
|
56
|
+
# "facet_field" -- the name of a facet field: language_facet
|
57
|
+
# "params" -- the standard #search method params
|
58
|
+
# Returns an instance of RSolr::Response::Query::Base
|
59
|
+
def search_facet_by_name(facet_field, params, &blk)
|
60
|
+
params[:per_page] = 0
|
61
|
+
params[:rows] = 0
|
62
|
+
params[:facets] ||= {}
|
63
|
+
params[:facets][:fields] = [facet_field]
|
64
|
+
params[:facets][:mincount] ||= 1
|
65
|
+
params[:facets][:prefix] ||= nil
|
66
|
+
params[:facets][:missing] ||= false
|
67
|
+
params[:facets][:sort] ||= :count
|
68
|
+
params[:facets][:offset] ||= 0
|
69
|
+
self.search(params, &blk)
|
70
|
+
end
|
71
|
+
|
56
72
|
# Finds a document by its id
|
57
73
|
def find_by_id(id, params={})
|
58
74
|
params = map_params(params)
|
data/lib/rsolr.rb
CHANGED
@@ -116,4 +116,13 @@ module ConnectionTestMethods
|
|
116
116
|
assert [true, false].include?(response.has_deletions?)
|
117
117
|
end
|
118
118
|
|
119
|
+
def test_search_facet_by_name
|
120
|
+
@solr.add([{:id=>1, :cat=>'eletronics'}, {:id=>2, :cat=>'software'}]) and @solr.commit
|
121
|
+
response = @solr.search_facet_by_name('cat', {:q=>'*:*'})
|
122
|
+
assert_equal 2, response.facet_field_values(:cat).size
|
123
|
+
#
|
124
|
+
response = @solr.search_facet_by_name('cat', {:q=>'*:*'})
|
125
|
+
assert_equal 0, response.docs.size
|
126
|
+
end
|
127
|
+
|
119
128
|
end
|