europeana-blacklight 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56ad04523f752587c4b28ffe8115eaa6b6de4b44
4
- data.tar.gz: 249cefb4cece87713a7d42e7c1c311871f72acb9
3
+ metadata.gz: 83d5b7488e74357b03a95438f478a61b65b170eb
4
+ data.tar.gz: 168a4be610d544986d85c053c075c4b064692446
5
5
  SHA512:
6
- metadata.gz: baedf8ef132c38592f47ac4ac3bee19fc10fb1d3475e4a15d33d37ee9bf9d6405ca40af9a22afa113fb5b5218216d701b726ebc703f52b2915df8da1e1b62687
7
- data.tar.gz: 97a4143b8bd29f3a3d7f2e0fcef19ef3072a824a392261a7407332c0c71422817da37504ade2ceefb00b28675936c55cf2ceaeb187b97a55399f179f8b25d5e8
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 }.each_with_object({}) do |(field_name, facet_field), hash|
131
- salient_facet_queries = facet_field.query.map { |_k, x| x[:fq] }
132
- items = []
133
- facet_queries.select { |k, _v| salient_facet_queries.include?(k) }.reject { |_value, hits| hits == 0 }.map do |value, hits|
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
- items << FacetItem.new(value: key, hits: hits, label: facet_field.query[key][:label])
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
@@ -1,6 +1,6 @@
1
1
  module Europeana
2
2
  #:nodoc:
3
3
  module Blacklight
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
6
6
  end
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.0
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-22 00:00:00.000000000 Z
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.8
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