Sha256: 4ffa4f54354c422a3a43f85f2e56f019bf7365e4dba02027ef3c12766e00919c

Contents?: true

Size: 1.25 KB

Versions: 21

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

module Blacklight::Solr
  # Pagination for facet values -- works by setting the limit to max
  # displayable. You have to ask Solr for limit+1, to get enough
  # results to see if 'more' are available'. That is, the all_facet_values
  # arg in constructor should be the result of asking solr for limit+1
  # values.
  # This is a workaround for the fact that Solr itself can't compute
  # the total values for a given facet field,
  # so we cannot know how many "pages" there are.
  #
  class FacetPaginator < Blacklight::FacetPaginator
    # all_facet_values is a list of facet value objects returned by solr,
    # asking solr for n+1 facet values.
    # options:
    # :limit =>  number to display per page, or (default) nil. Nil means
    #            display all with no previous or next.
    # :offset => current item offset, default 0
    # :sort => 'count' or 'index', solr tokens for facet value sorting, default 'count'.
    def initialize(all_facet_values, arguments = {})
      super

      @sort = arguments[:sort].keys.first.to_s if arguments[:sort].is_a? Hash

      # count is solr's default
      @sort ||= if @limit.to_i > 0
                  'count'
                else
                  'index'
                end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
blacklight-8.6.1 lib/blacklight/solr/facet_paginator.rb
blacklight-8.6.0 lib/blacklight/solr/facet_paginator.rb
blacklight-8.5.1 lib/blacklight/solr/facet_paginator.rb
blacklight-8.5.0 lib/blacklight/solr/facet_paginator.rb
blacklight-8.4.0 lib/blacklight/solr/facet_paginator.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/lib/blacklight/solr/facet_paginator.rb
blacklight-8.3.0 lib/blacklight/solr/facet_paginator.rb
blacklight-8.2.2 lib/blacklight/solr/facet_paginator.rb
blacklight-8.2.1 lib/blacklight/solr/facet_paginator.rb
blacklight-8.2.0 lib/blacklight/solr/facet_paginator.rb
blacklight-8.1.0 lib/blacklight/solr/facet_paginator.rb
blacklight-8.0.1 lib/blacklight/solr/facet_paginator.rb
blacklight-8.0.0 lib/blacklight/solr/facet_paginator.rb
blacklight-8.0.0.beta8 lib/blacklight/solr/facet_paginator.rb
blacklight-8.0.0.beta7 lib/blacklight/solr/facet_paginator.rb
blacklight-8.0.0.beta6 lib/blacklight/solr/facet_paginator.rb
blacklight-8.0.0.beta5 lib/blacklight/solr/facet_paginator.rb
blacklight-8.0.0.beta4 lib/blacklight/solr/facet_paginator.rb
blacklight-8.0.0.beta3 lib/blacklight/solr/facet_paginator.rb
blacklight-8.0.0.beta2 lib/blacklight/solr/facet_paginator.rb