europeana-blacklight 0.2.0 → 0.2.1
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83d5b7488e74357b03a95438f478a61b65b170eb
|
4
|
+
data.tar.gz: 168a4be610d544986d85c053c075c4b064692446
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 450e5219a9a6e07628d18072bdd36cc0ab9796b454047d5ee871eff58bc39f9b73a31e5d9d64793ccb834780a696dd1d609f6e7a39b682e9d91bfca72e7a49ce
|
7
|
+
data.tar.gz: 5083dbcfa6ae7c160fa5f551b8a3b2b0dd829163aa7ce5175606e071b60557403701a8ff0fbe1530af4d302bbe2a3cf5e8b00ad28581e0ce625e073f3a1af105
|
data/README.md
CHANGED
@@ -57,3 +57,21 @@ And then execute:
|
|
57
57
|
config.europeana_api_cache_expires_in = 60.minutes # defaults to 24.hours
|
58
58
|
end
|
59
59
|
```
|
60
|
+
|
61
|
+
## Query facets
|
62
|
+
|
63
|
+
In the configuration for query facet fields, the `:fq` option is a `Hash`, to
|
64
|
+
permit specification of multiple parameters to be passed to the API:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
configure_blacklight do |config|
|
68
|
+
config.add_facet_field 'Cities (reusable content)', query: [
|
69
|
+
{ label: 'Paris', fq: { qf: 'paris', reusability: 'open' } },
|
70
|
+
{ label: 'Berlin', fq: { qf: 'berlin', reusability: 'open' } }
|
71
|
+
]
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
*Warning:* query facets are achieved by sending additional queries to the
|
76
|
+
API. If you configure 10 query facets, this will result in an additional
|
77
|
+
10 queries being sent to the API.
|
@@ -127,13 +127,17 @@ module Europeana
|
|
127
127
|
def facet_query_aggregations
|
128
128
|
return {} unless blacklight_config
|
129
129
|
|
130
|
-
blacklight_config.facet_fields.select { |_k, v| v.query }
|
131
|
-
|
132
|
-
|
133
|
-
|
130
|
+
query_facet_fields = blacklight_config.facet_fields.select { |_k, v| v.query }
|
131
|
+
query_facet_fields.each_with_object({}) do |(field_name, facet_field), hash|
|
132
|
+
facet_query_params = facet_field.query.map { |_k, v| v[:fq] }
|
133
|
+
response_facet_queries = facet_queries.dup
|
134
|
+
response_facet_queries.select! { |k, _hits| facet_query_params.include?(k) }
|
135
|
+
response_facet_queries.reject! { |_k, hits| hits == 0 }
|
136
|
+
|
137
|
+
items = response_facet_queries.map do |value, hits|
|
134
138
|
salient_fields = facet_field.query.select { |_k, v| v[:fq] == value }
|
135
139
|
key = ((salient_fields.keys if salient_fields.respond_to? :keys) || salient_fields.first).first
|
136
|
-
|
140
|
+
FacetItem.new(value: key, hits: hits, label: facet_field.query[key][:label])
|
137
141
|
end
|
138
142
|
|
139
143
|
hash[field_name] = FacetField.new(field_name, items)
|
@@ -3,7 +3,6 @@ module Europeana
|
|
3
3
|
##
|
4
4
|
# Core search builder for {Europeana::Blacklight::ApiRepository}
|
5
5
|
class SearchBuilder < ::Blacklight::SearchBuilder
|
6
|
-
require 'europeana/blacklight/search_builder/channels'
|
7
6
|
require 'europeana/blacklight/search_builder/facet_pagination'
|
8
7
|
require 'europeana/blacklight/search_builder/more_like_this'
|
9
8
|
require 'europeana/blacklight/search_builder/ranges'
|
@@ -15,7 +14,6 @@ module Europeana
|
|
15
14
|
:add_sorting_to_api
|
16
15
|
]
|
17
16
|
|
18
|
-
include Channels
|
19
17
|
include FacetPagination
|
20
18
|
include MoreLikeThis
|
21
19
|
include Ranges
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: europeana-blacklight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Doe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: blacklight
|
@@ -132,7 +132,6 @@ files:
|
|
132
132
|
- lib/europeana/blacklight/response/more_like_this.rb
|
133
133
|
- lib/europeana/blacklight/response/pagination.rb
|
134
134
|
- lib/europeana/blacklight/search_builder.rb
|
135
|
-
- lib/europeana/blacklight/search_builder/channels.rb
|
136
135
|
- lib/europeana/blacklight/search_builder/facet_pagination.rb
|
137
136
|
- lib/europeana/blacklight/search_builder/more_like_this.rb
|
138
137
|
- lib/europeana/blacklight/search_builder/ranges.rb
|
@@ -157,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
156
|
version: '0'
|
158
157
|
requirements: []
|
159
158
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.4.
|
159
|
+
rubygems_version: 2.4.6
|
161
160
|
signing_key:
|
162
161
|
specification_version: 4
|
163
162
|
summary: Europeana REST API adapter for Blacklight
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Europeana
|
2
|
-
module Blacklight
|
3
|
-
class SearchBuilder
|
4
|
-
##
|
5
|
-
# Search builder with content channel qf
|
6
|
-
module Channels
|
7
|
-
# @todo remove hard-coded controller check
|
8
|
-
def add_channel_qf_to_api(api_parameters)
|
9
|
-
return unless blacklight_params[:controller] == 'channels' && blacklight_params[:id].present?
|
10
|
-
channel_qf = scope.channels_search_query
|
11
|
-
return if channel_qf.blank?
|
12
|
-
api_parameters[:qf] ||= []
|
13
|
-
api_parameters[:qf] << channel_qf
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|