Class: Spotlight::FieldMetadata
- Inherits:
-
Object
- Object
- Spotlight::FieldMetadata
- Includes:
- SearchHelper
- Defined in:
- app/models/spotlight/field_metadata.rb
Overview
Expose Solr index metadata about fields
Constant Summary collapse
- FACET_LIMIT =
20
Instance Attribute Summary collapse
-
#blacklight_config ⇒ Object
readonly
Returns the value of attribute blacklight_config.
-
#exhibit ⇒ Object
(also: #current_exhibit)
readonly
Returns the value of attribute exhibit.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Instance Method Summary collapse
- #field(key) ⇒ Object
-
#initialize(exhibit, repository, blacklight_config) ⇒ FieldMetadata
constructor
A new instance of FieldMetadata.
- #search_params ⇒ Object
Methods included from SearchHelper
#search_service, #search_service_context
Constructor Details
#initialize(exhibit, repository, blacklight_config) ⇒ FieldMetadata
Returns a new instance of FieldMetadata.
13 14 15 16 17 |
# File 'app/models/spotlight/field_metadata.rb', line 13 def initialize(exhibit, repository, blacklight_config) @exhibit = exhibit @repository = repository @blacklight_config = blacklight_config end |
Instance Attribute Details
#blacklight_config ⇒ Object (readonly)
Returns the value of attribute blacklight_config.
11 12 13 |
# File 'app/models/spotlight/field_metadata.rb', line 11 def blacklight_config @blacklight_config end |
#exhibit ⇒ Object (readonly) Also known as: current_exhibit
Returns the value of attribute exhibit.
11 12 13 |
# File 'app/models/spotlight/field_metadata.rb', line 11 def exhibit @exhibit end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
11 12 13 |
# File 'app/models/spotlight/field_metadata.rb', line 11 def repository @repository end |
Instance Method Details
#field(key) ⇒ Object
19 20 21 22 23 24 |
# File 'app/models/spotlight/field_metadata.rb', line 19 def field(key) { document_count: document_counts.fetch(field_name(key), 0), value_count: terms.fetch(field_name(key), []).length } end |
#search_params ⇒ Object
26 27 28 |
# File 'app/models/spotlight/field_metadata.rb', line 26 def search_params search_service.search_builder.merge(rows: 0, 'facet.limit' => FACET_LIMIT + 1) end |