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 +4 -4
- data/lib/response.rb +11 -0
- data/lib/search_params.rb +8 -3
- data/lib/solr.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c12cae699f561e5b32fd44b2969b7ab8756b5bf49b25f0a97c0ec3b67dc574ee
|
|
4
|
+
data.tar.gz: a642e417596a331ad88c7f5a9fcd436fe63167eabe415535ef0e36967901474e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
#
|
|
36
|
+
# [Bool] Set to true to request hit highlighting information from Solr.
|
|
37
37
|
attr_accessor :hl
|
|
38
38
|
|
|
39
|
-
#
|
|
39
|
+
# [String] Sets the highlight fields (hl.fl) to request from Solr.
|
|
40
40
|
attr_accessor :hl_fl
|
|
41
41
|
|
|
42
|
-
#
|
|
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.
|
|
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-
|
|
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.
|