Class: Krikri::IndexService
- Inherits:
-
Object
- Object
- Krikri::IndexService
- Defined in:
- lib/krikri/index_service.rb
Overview
Generates flattened Solr documents and manages indexing of DPLA MAP models.
Class Method Summary collapse
-
.add(doc) ⇒ Object
Adds a single JSON document to Solr.
-
.commit ⇒ Object
Commits changes to Solr, making them visible to new requests Should be run after self.add and self.delete Okay to add or delete multiple docs and commit them all with a single self.commit.
-
.delete_by_id(id) ⇒ Object
Deletes an item from Solr.
-
.delete_by_query(query) ⇒ Object
Deletes items from Solr that match query.
-
.schema_keys ⇒ Array
Get field names from Solr schema in host application.
Class Method Details
.add(doc) ⇒ Object
Adds a single JSON document to Solr
16 17 18 |
# File 'lib/krikri/index_service.rb', line 16 def self.add(doc) @solr.add solr_doc(doc) end |
.commit ⇒ Object
Commits changes to Solr, making them visible to new requests Should be run after self.add and self.delete Okay to add or delete multiple docs and commit them all with a single self.commit
39 40 41 |
# File 'lib/krikri/index_service.rb', line 39 def self.commit @solr.commit end |
.delete_by_id(id) ⇒ Object
Deletes an item from Solr
23 24 25 |
# File 'lib/krikri/index_service.rb', line 23 def self.delete_by_id(id) @solr.delete_by_id id end |
.delete_by_query(query) ⇒ Object
Deletes items from Solr that match query
30 31 32 |
# File 'lib/krikri/index_service.rb', line 30 def self.delete_by_query(query) @solr.delete_by_query query end |
.schema_keys ⇒ Array
Get field names from Solr schema in host application. Will raise exception if file not found.
64 65 66 67 68 69 70 |
# File 'lib/krikri/index_service.rb', line 64 def self.schema_keys schema_file = File.join(Rails.root, 'solr_conf', 'schema.xml') file = File.open(schema_file) doc = Nokogiri::XML(file) file.close doc.xpath('//fields/field').map { |f| f.attr('name') } end |