Sha256: 3210ed79d1b10d788a6dcd6b5aceea586198a3a22389384df763bb898bbd13f0

Contents?: true

Size: 1.18 KB

Versions: 31

Compression:

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

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

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
blacklight-7.16.0 lib/blacklight/solr/facet_paginator.rb
blacklight-7.15.2 lib/blacklight/solr/facet_paginator.rb
blacklight-7.15.1 lib/blacklight/solr/facet_paginator.rb
blacklight-7.15.0 lib/blacklight/solr/facet_paginator.rb
blacklight-7.14.1 lib/blacklight/solr/facet_paginator.rb
blacklight-7.14.0 lib/blacklight/solr/facet_paginator.rb
blacklight-7.13.2 lib/blacklight/solr/facet_paginator.rb
blacklight-7.13.1 lib/blacklight/solr/facet_paginator.rb
blacklight-7.13.0 lib/blacklight/solr/facet_paginator.rb
blacklight-7.12.1 lib/blacklight/solr/facet_paginator.rb
blacklight-7.12.0 lib/blacklight/solr/facet_paginator.rb
blacklight-7.11.1 lib/blacklight/solr/facet_paginator.rb
blacklight-7.10.0 lib/blacklight/solr/facet_paginator.rb
blacklight-7.9.0 lib/blacklight/solr/facet_paginator.rb
blacklight-7.8.1 lib/blacklight/solr/facet_paginator.rb
blacklight-7.8.0 lib/blacklight/solr/facet_paginator.rb
blacklight-7.7.0 lib/blacklight/solr/facet_paginator.rb
blacklight-7.6.0 lib/blacklight/solr/facet_paginator.rb
blacklight-7.5.1 lib/blacklight/solr/facet_paginator.rb
blacklight-7.5.0 lib/blacklight/solr/facet_paginator.rb