Class: Blacklight::Solr::Request
- Inherits:
-
ActiveSupport::HashWithIndifferentAccess
- Object
- ActiveSupport::HashWithIndifferentAccess
- Blacklight::Solr::Request
- Defined in:
- lib/blacklight/solr/request.rb
Constant Summary collapse
- SINGULAR_KEYS =
Deprecated.
%w(facet fl q qt rows start spellcheck spellcheck.q sort per_page wt hl group defType)
- ARRAY_KEYS =
Deprecated.
%w(facet.field facet.query facet.pivot fq hl.fl)
Instance Method Summary collapse
- #append_boolean_query(bool_operator, query) ⇒ Object
- #append_facet_fields(values) ⇒ Object
- #append_facet_pivot(query) ⇒ Object
- #append_facet_query(values) ⇒ Object
- #append_filter_query(query) ⇒ Object
- #append_highlight_field(query) ⇒ Object
- #append_query(query) ⇒ Object
-
#initialize(constructor = {}) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(constructor = {}) ⇒ Request
Returns a new instance of Request.
12 13 14 15 16 17 18 19 |
# File 'lib/blacklight/solr/request.rb', line 12 def initialize(constructor = {}) if constructor.is_a?(Hash) super() update(constructor) else super end end |
Instance Method Details
#append_boolean_query(bool_operator, query) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/blacklight/solr/request.rb', line 38 def append_boolean_query(bool_operator, query) return if query.blank? self[:json] ||= { query: { bool: { bool_operator => [] } } } self[:json][:query] ||= { bool: { bool_operator => [] } } self[:json][:query][:bool][bool_operator] ||= [] if self['q'] self[:json][:query][:bool][:must] ||= [] self[:json][:query][:bool][:must] << self['q'] delete 'q' end self[:json][:query][:bool][bool_operator] << query end |
#append_facet_fields(values) ⇒ Object
61 62 63 64 |
# File 'lib/blacklight/solr/request.rb', line 61 def append_facet_fields(values) self['facet.field'] ||= [] self['facet.field'] += Array(values) end |
#append_facet_pivot(query) ⇒ Object
71 72 73 74 |
# File 'lib/blacklight/solr/request.rb', line 71 def append_facet_pivot(query) self['facet.pivot'] ||= [] self['facet.pivot'] << query end |
#append_facet_query(values) ⇒ Object
66 67 68 69 |
# File 'lib/blacklight/solr/request.rb', line 66 def append_facet_query(values) self['facet.query'] ||= [] self['facet.query'] += Array(values) end |
#append_filter_query(query) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/blacklight/solr/request.rb', line 54 def append_filter_query(query) self['fq'] ||= [] self['fq'] = Array(self['fq']) if self['fq'].is_a? String self['fq'] << query end |
#append_highlight_field(query) ⇒ Object
76 77 78 79 |
# File 'lib/blacklight/solr/request.rb', line 76 def append_highlight_field(query) self['hl.fl'] ||= [] self['hl.fl'] << query end |
#append_query(query) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/blacklight/solr/request.rb', line 21 def append_query(query) return if query.nil? if self['q'] || dig(:json, :query, :bool) self[:json] ||= { query: { bool: { must: [] } } } self[:json][:query] ||= { bool: { must: [] } } self[:json][:query][:bool][:must] << query if self['q'] self[:json][:query][:bool][:must] << self['q'] delete 'q' end else self['q'] = query end end |