Class: Valkyrie::Persistence::Solr::Queries::FindInverseReferencesQuery
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::Solr::Queries::FindInverseReferencesQuery
- Defined in:
- lib/valkyrie/persistence/solr/queries/find_inverse_references_query.rb
Overview
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#property ⇒ Object
readonly
Returns the value of attribute property.
-
#resource_factory ⇒ Object
readonly
Returns the value of attribute resource_factory.
Instance Method Summary collapse
-
#each {|Valkyrie::Resource| ... } ⇒ Object
Queries for all Documents in the Solr index For each Document, it yields the Valkyrie Resource which was converted from it.
-
#initialize(resource: nil, id: nil, property:, connection:, resource_factory:) ⇒ FindInverseReferencesQuery
constructor
A new instance of FindInverseReferencesQuery.
-
#query ⇒ Hash
Query Solr for for all documents with the ID in the requested field.
-
#run ⇒ Array<Valkyrie::Resource>
Iterate over each Solr Document and convert each Document into a Valkyrie Resource.
Constructor Details
#initialize(resource: nil, id: nil, property:, connection:, resource_factory:) ⇒ FindInverseReferencesQuery
Returns a new instance of FindInverseReferencesQuery.
12 13 14 15 16 17 |
# File 'lib/valkyrie/persistence/solr/queries/find_inverse_references_query.rb', line 12 def initialize(resource: nil, id: nil, property:, connection:, resource_factory:) @id = id ? id : resource.id @property = property @connection = connection @resource_factory = resource_factory end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/valkyrie/persistence/solr/queries/find_inverse_references_query.rb', line 6 def connection @connection end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/valkyrie/persistence/solr/queries/find_inverse_references_query.rb', line 6 def id @id end |
#property ⇒ Object (readonly)
Returns the value of attribute property.
6 7 8 |
# File 'lib/valkyrie/persistence/solr/queries/find_inverse_references_query.rb', line 6 def property @property end |
#resource_factory ⇒ Object (readonly)
Returns the value of attribute resource_factory.
6 7 8 |
# File 'lib/valkyrie/persistence/solr/queries/find_inverse_references_query.rb', line 6 def resource_factory @resource_factory end |
Instance Method Details
#each {|Valkyrie::Resource| ... } ⇒ Object
Queries for all Documents in the Solr index For each Document, it yields the Valkyrie Resource which was converted from it
28 29 30 31 32 33 34 35 36 |
# File 'lib/valkyrie/persistence/solr/queries/find_inverse_references_query.rb', line 28 def each docs = DefaultPaginator.new while docs.has_next? docs = connection.paginate(docs.next_page, docs.per_page, "select", params: { q: query })["response"]["docs"] docs.each do |doc| yield resource_factory.to_resource(object: doc) end end end |
#query ⇒ Hash
the field used here is a _ssim dynamic field and the value is prefixed by “id-”
Query Solr for for all documents with the ID in the requested field
41 42 43 |
# File 'lib/valkyrie/persistence/solr/queries/find_inverse_references_query.rb', line 41 def query "#{property}_ssim:id-#{id}" end |
#run ⇒ Array<Valkyrie::Resource>
Iterate over each Solr Document and convert each Document into a Valkyrie Resource
21 22 23 |
# File 'lib/valkyrie/persistence/solr/queries/find_inverse_references_query.rb', line 21 def run enum_for(:each) end |