Sha256: 6b62d8bd5bdefddd695302c914012c0ed3c7731ae0cbb47b0986b99a3b8f87e4

Contents?: true

Size: 975 Bytes

Versions: 32

Compression:

Stored size: 975 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

32 entries across 32 versions & 1 rubygems

Version Path
blacklight-5.13.0 lib/blacklight/solr/request.rb
blacklight-5.11.3 lib/blacklight/solr/request.rb
blacklight-5.12.1 lib/blacklight/solr/request.rb
blacklight-5.12.0 lib/blacklight/solr/request.rb
blacklight-5.10.3 lib/blacklight/solr/request.rb
blacklight-5.9.4 lib/blacklight/solr/request.rb
blacklight-5.11.2 lib/blacklight/solr/request.rb
blacklight-5.11.1 lib/blacklight/solr/request.rb
blacklight-5.11.0 lib/blacklight/solr/request.rb
blacklight-5.10.2 lib/blacklight/solr/request.rb
blacklight-5.10.1 lib/blacklight/solr/request.rb
blacklight-5.10.0 lib/blacklight/solr/request.rb
blacklight-5.9.3 lib/blacklight/solr/request.rb
blacklight-5.9.2 lib/blacklight/solr/request.rb
blacklight-5.9.1 lib/blacklight/solr/request.rb
blacklight-5.9.0 lib/blacklight/solr/request.rb
blacklight-5.8.2 lib/blacklight/solr/request.rb
blacklight-5.8.1 lib/blacklight/solr/request.rb
blacklight-5.8.0 lib/blacklight/solr/request.rb
blacklight-5.7.2 lib/blacklight/solr/request.rb