mwmitchell-rsolr 0.6.7 → 0.6.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/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, :facet.limit=>-1, :facet.field=>'cat', :facet.field=>'inStock')
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
@@ -7,7 +7,7 @@ proc {|base, files|
7
7
 
8
8
  module RSolr
9
9
 
10
- VERSION = '0.6.7'
10
+ VERSION = '0.6.8'
11
11
 
12
12
  autoload :Message, 'rsolr/message'
13
13
  autoload :Response, 'rsolr/response'
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mwmitchell-rsolr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.7
4
+ version: 0.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Mitchell