solr_lite 0.0.13 → 0.0.14

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04c666a78bdf04147350b03ee3f430fdafe36cabfc5d5869538dbbf1e7a963d9
4
- data.tar.gz: cee4e1f082d4a9cbae8ee9e6fb136efd4a20562648a324d62cc7d040d38b672b
3
+ metadata.gz: c12cae699f561e5b32fd44b2969b7ab8756b5bf49b25f0a97c0ec3b67dc574ee
4
+ data.tar.gz: a642e417596a331ad88c7f5a9fcd436fe63167eabe415535ef0e36967901474e
5
5
  SHA512:
6
- metadata.gz: 23b83c4f7e1f495631f9f01f4f939828a0dbfe78f06397fd2873e99fa2e7b722bf960c7412da0a89be914976b9eaed4a51cf6c9133e66dc674414a6e29d2b7c2
7
- data.tar.gz: 62cbe1329b68a5529c1e0b6c916261d1da9a56fcc9a44981a748a0a1dc34fc44db1713b2e2a50f5601631418fc64698844c508c85d5e91f7e3d3f0f1a5510602
6
+ metadata.gz: 57ba843c385af774dfa08294e1befb38ef0015ef716059b91448343627d55be0a99767208e644bf8786fa6db225fd1906eaf9bbe43b277e0cb31b9261e247f07
7
+ data.tar.gz: 9f0e1d4aa2bf17df4ba54df5e6440d1e93ad7fb4043c9a40a7457e7f971166fab62a053eee7ebd15c65f0ba90d2690e67f77748712ce7b2b0b214c034c33c618
data/lib/response.rb CHANGED
@@ -60,6 +60,17 @@ module SolrLite
60
60
  0
61
61
  end
62
62
 
63
+ # Total number of groups found in Solr
64
+ # for a grouped request.
65
+ def groups_found
66
+ if @solr_response["grouped"] != nil && @params.group_count != nil
67
+ return @solr_response["facets"][@params.group_count]
68
+ end
69
+ return 0
70
+ rescue
71
+ 0
72
+ end
73
+
63
74
  # Total number documents found in Solr
64
75
  # for a given group field/value/
65
76
  def num_found_for_group(group_field, group_value)
data/lib/search_params.rb CHANGED
@@ -33,15 +33,19 @@ module SolrLite
33
33
  # [Bool] True to request Solr to use spellchecking (defaults to false).
34
34
  attr_accessor :spellcheck
35
35
 
36
- # [Bool] Set to true to request hit highlighting information from Solr.
36
+ # [Bool] Set to true to request hit highlighting information from Solr.
37
37
  attr_accessor :hl
38
38
 
39
- # [String] Sets the highlight fields (hl.fl) to request from Solr.
39
+ # [String] Sets the highlight fields (hl.fl) to request from Solr.
40
40
  attr_accessor :hl_fl
41
41
 
42
- # [Integer] Sets the number of hit highlights to request from Solr.
42
+ # [Integer] Sets the number of hit highlights to request from Solr.
43
43
  attr_accessor :hl_snippets
44
44
 
45
+ # [String] The name of the value in the response to hold the number of groups found
46
+ # in a grouped request. Defaults to "group_count", set to nil to omit.
47
+ attr_accessor :group_count
48
+
45
49
  DEFAULT_PAGE_SIZE = 20
46
50
 
47
51
  # Creates an instance of the SearchParams class.
@@ -64,6 +68,7 @@ module SolrLite
64
68
  @hl = false
65
69
  @hl_fl = nil
66
70
  @hl_snippets = 1
71
+ @group_count = "group_count"
67
72
  end
68
73
 
69
74
  # Returns facet information about a given field.
data/lib/solr.rb CHANGED
@@ -182,6 +182,16 @@ module SolrLite
182
182
  # See https://lucene.apache.org/solr/guide/7_0/result-grouping.html
183
183
  # and https://wiki.apache.org/solr/FieldCollapsing
184
184
  query_string += "&group=true&group.field=#{group_field}&group.limit=#{group_limit}"
185
+
186
+ if params.group_count != nil
187
+ # Adds an extra calculated facet to get the total number of groups. This is required
188
+ # because Solr does not return this value in the response, instead Solr
189
+ # returns the total number of documents found across all groups, but not
190
+ # the total number of groups found.
191
+ # See https://lucene.apache.org/solr/guide/7_7/json-facet-api.html#metrics-example
192
+ # and https://stackoverflow.com/a/56138991/446681
193
+ query_string += '&json.facet={"' + params.group_count + '":"unique(' + group_field + ')"}'
194
+ end
185
195
  end
186
196
 
187
197
  if @def_type != nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solr_lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hector Correa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-02 00:00:00.000000000 Z
11
+ date: 2019-05-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A lightweight gem to connect to Solr and run queries. Requires no extra
14
14
  dependencies.