Class: ActiveFedora::Indexing::Inserter
- Inherits:
-
Object
- Object
- ActiveFedora::Indexing::Inserter
- Defined in:
- lib/active_fedora/indexing/inserter.rb
Overview
Utilities for adding fields to index documents
Class Method Summary collapse
-
.create_and_insert_terms(field_name_base, value, index_as, solr_doc) ⇒ Object
@example: solr_doc = {} create_and_insert_terms(‘title’, ‘War and Peace’, [:displayable, :searchable], solr_doc) solr_doc # => and Peace”], “title_teim”=>[“War and Peace”].
- .insert_field(doc, name, value, *indexer_args) ⇒ Object
Class Method Details
.create_and_insert_terms(field_name_base, value, index_as, solr_doc) ⇒ Object
@example:
solr_doc = {}
create_and_insert_terms('title', 'War and Peace', [:displayable, :searchable], solr_doc)
solr_doc
# => {"title_ssm"=>["War and Peace"], "title_teim"=>["War and Peace"]}
14 15 16 17 18 |
# File 'lib/active_fedora/indexing/inserter.rb', line 14 def self.create_and_insert_terms(field_name_base, value, index_as, solr_doc) index_as.each do |indexer| insert_field(solr_doc, field_name_base, value, indexer) end end |
.insert_field(doc, name, value, *indexer_args) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/active_fedora/indexing/inserter.rb', line 25 def self.insert_field(doc, name, value, *indexer_args) # adding defaults indexer indexer_args = [:stored_searchable] if indexer_args.empty? ActiveFedora.index_field_mapper.solr_names_and_values(name, value, indexer_args).each do |k, v| doc[k] ||= [] if v.is_a? Array doc[k] += v else doc[k] = v end end doc end |