Class: Valkyrie::Indexing::Solr::IndexingAdapter
- Inherits:
-
Object
- Object
- Valkyrie::Indexing::Solr::IndexingAdapter
- Defined in:
- lib/valkyrie/indexing/solr/indexing_adapter.rb
Constant Summary collapse
- COMMIT_PARAMS =
{ softCommit: true }.freeze
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#delete(resource:) ⇒ Array<Valkyrie::Resource>
Deletes a Solr Document using the ID.
-
#initialize(connection: default_connection) ⇒ IndexingAdapter
constructor
A new instance of IndexingAdapter.
- #reset! ⇒ Object
- #save(resource:) ⇒ Object
- #save_all(resources:) ⇒ Object
-
#wipe! ⇒ Object
Delete the Solr index of all Documents.
Constructor Details
#initialize(connection: default_connection) ⇒ IndexingAdapter
Returns a new instance of IndexingAdapter.
16 17 18 |
# File 'lib/valkyrie/indexing/solr/indexing_adapter.rb', line 16 def initialize(connection: default_connection) @connection = connection end |
Instance Attribute Details
#connection ⇒ RSolr::Client
12 13 14 |
# File 'lib/valkyrie/indexing/solr/indexing_adapter.rb', line 12 def connection @connection end |
Instance Method Details
#delete(resource:) ⇒ Array<Valkyrie::Resource>
Deletes a Solr Document using the ID
30 31 32 |
# File 'lib/valkyrie/indexing/solr/indexing_adapter.rb', line 30 def delete(resource:) connection.delete_by_id resource.id.to_s, params: COMMIT_PARAMS end |
#reset! ⇒ Object
40 41 42 |
# File 'lib/valkyrie/indexing/solr/indexing_adapter.rb', line 40 def reset! self.connection = default_connection end |
#save(resource:) ⇒ Object
20 21 22 |
# File 'lib/valkyrie/indexing/solr/indexing_adapter.rb', line 20 def save(resource:) persist([resource]) end |
#save_all(resources:) ⇒ Object
24 25 26 |
# File 'lib/valkyrie/indexing/solr/indexing_adapter.rb', line 24 def save_all(resources:) persist(resources) end |
#wipe! ⇒ Object
Delete the Solr index of all Documents
35 36 37 38 |
# File 'lib/valkyrie/indexing/solr/indexing_adapter.rb', line 35 def wipe! connection.delete_by_query("*:*") connection.commit end |