Sha256: dc5c209c3e57dbcb110a1abfcc7d1edb4272998846dadb1e88a2fd6368cf894c

Contents?: true

Size: 970 Bytes

Versions: 19

Compression:

Stored size: 970 Bytes

Contents

class Blacklight::Solr::InvalidParameter < ArgumentError; end

class Blacklight::Solr::Request < HashWithIndifferentAccess

  SINGULAR_KEYS = %w{facet fl q qt rows start spellcheck spellcheck.q sort per_page wt hl group defType}
  ARRAY_KEYS = %w{facet.field facet.query facet.pivot fq hl.fl}

  def initialize(constructor = {})
    if constructor.is_a?(Hash)
      super()
      update(constructor)
    else
      super(constructor)
    end
    ARRAY_KEYS.each do |key|
      self[key] ||= []
    end
  end

  def append_filter_query(query)
    self['fq'] << query
  end

  def append_facet_fields(values)
    self['facet.field'] += Array(values)
  end

  def append_facet_query(values)
    self['facet.query'] += Array(values)
  end

  def append_facet_pivot(query)
    self['facet.pivot'] << query
  end

  def append_highlight_field(query)
    self['hl.fl'] << query
  end

  def to_hash
    reject {|key, value| ARRAY_KEYS.include?(key) && value.blank?}
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
blacklight-5.19.2 lib/blacklight/solr/request.rb
blacklight-5.19.1 lib/blacklight/solr/request.rb
blacklight-5.19.0 lib/blacklight/solr/request.rb
blacklight-5.18.0 lib/blacklight/solr/request.rb
blacklight-5.17.2 lib/blacklight/solr/request.rb
blacklight-5.17.1 lib/blacklight/solr/request.rb
blacklight-5.17.0 lib/blacklight/solr/request.rb
blacklight-6.0.0.pre4 lib/blacklight/solr/request.rb
blacklight-5.16.4 lib/blacklight/solr/request.rb
blacklight-6.0.0.pre3 lib/blacklight/solr/request.rb
blacklight-5.16.3 lib/blacklight/solr/request.rb
blacklight-5.16.2 lib/blacklight/solr/request.rb
blacklight-5.16.1 lib/blacklight/solr/request.rb
blacklight-6.0.0.pre2 lib/blacklight/solr/request.rb
blacklight-6.0.0.pre1 app/models/blacklight/solr/request.rb
blacklight-5.16.0 app/models/blacklight/solr/request.rb
blacklight-5.15.0 lib/blacklight/solr/request.rb
blacklight-5.14.0 lib/blacklight/solr/request.rb
blacklight-5.13.1 lib/blacklight/solr/request.rb