Class: Valkyrie::Persistence::Solr::Persister
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::Solr::Persister
- Defined in:
- lib/valkyrie/persistence/solr/persister.rb
Overview
Persister for Solr MetadataAdapter.
Most methods are delegated to Repository
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Instance Method Summary collapse
- #delete(resource:) ⇒ Object
-
#initialize(adapter:) ⇒ Persister
constructor
A new instance of Persister.
- #repository(resources) ⇒ Object
-
#save(resource:) ⇒ Valkyrie::Resource
The resource with an ‘#id` value generated by the persistence backend.
-
#save_all(resources:) ⇒ Array<Valkyrie::Resource>
List of resources with an ‘#id` value generated by the persistence backend.
- #wipe! ⇒ Object
Constructor Details
#initialize(adapter:) ⇒ Persister
Returns a new instance of Persister.
12 13 14 |
# File 'lib/valkyrie/persistence/solr/persister.rb', line 12 def initialize(adapter:) @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
8 9 10 |
# File 'lib/valkyrie/persistence/solr/persister.rb', line 8 def adapter @adapter end |
Instance Method Details
#delete(resource:) ⇒ Object
35 36 37 |
# File 'lib/valkyrie/persistence/solr/persister.rb', line 35 def delete(resource:) repository([resource]).delete.first end |
#repository(resources) ⇒ Object
44 45 46 |
# File 'lib/valkyrie/persistence/solr/persister.rb', line 44 def repository(resources) Valkyrie::Persistence::Solr::Repository.new(resources: resources, connection: connection, resource_factory: resource_factory) end |
#save(resource:) ⇒ Valkyrie::Resource
Fields are saved using Solr’s dynamic fields functionality. If the text has length > 1000, it is stored as *_tsim otherwise it’s stored as *_tsim, *_ssim, and *_tesim e.g., a field called ‘title’ would be stored as 3 solr fields:
'title_tsim'
'title_ssim'
'title_tesim'
Returns The resource with an ‘#id` value generated by the persistence backend.
25 26 27 |
# File 'lib/valkyrie/persistence/solr/persister.rb', line 25 def save(resource:) repository([resource]).persist.first end |
#save_all(resources:) ⇒ Array<Valkyrie::Resource>
Returns List of resources with an ‘#id` value generated by the persistence backend.
30 31 32 |
# File 'lib/valkyrie/persistence/solr/persister.rb', line 30 def save_all(resources:) repository(resources).persist end |
#wipe! ⇒ Object
39 40 41 42 |
# File 'lib/valkyrie/persistence/solr/persister.rb', line 39 def wipe! connection.delete_by_query("*:*") connection.commit end |