Class: Valkyrie::Persistence::Solr::Queries::FindReferencesQuery
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::Solr::Queries::FindReferencesQuery
- Defined in:
- lib/valkyrie/persistence/solr/queries/find_references_query.rb
Overview
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#property ⇒ Object
readonly
Returns the value of attribute property.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#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.
-
#id ⇒ String
Retrieve the string value for the ID.
-
#initialize(resource:, property:, connection:, resource_factory:) ⇒ FindReferencesQuery
constructor
A new instance of FindReferencesQuery.
-
#query ⇒ String
Generate the Solr join query using the id_ssi field.
-
#run ⇒ Array<Valkyrie::Resource>
Iterate over each Solr Document and convert each Document into a Valkyrie Resource.
Constructor Details
#initialize(resource:, property:, connection:, resource_factory:) ⇒ FindReferencesQuery
Returns a new instance of FindReferencesQuery.
12 13 14 15 16 17 |
# File 'lib/valkyrie/persistence/solr/queries/find_references_query.rb', line 12 def initialize(resource:, property:, connection:, resource_factory:) @resource = resource @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_references_query.rb', line 6 def connection @connection end |
#property ⇒ Object (readonly)
Returns the value of attribute property.
6 7 8 |
# File 'lib/valkyrie/persistence/solr/queries/find_references_query.rb', line 6 def property @property end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
6 7 8 |
# File 'lib/valkyrie/persistence/solr/queries/find_references_query.rb', line 6 def resource @resource end |
#resource_factory ⇒ Object (readonly)
Returns the value of attribute resource_factory.
6 7 8 |
# File 'lib/valkyrie/persistence/solr/queries/find_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 37 38 |
# File 'lib/valkyrie/persistence/solr/queries/find_references_query.rb', line 28 def each docs = DefaultPaginator.new while docs.has_next? params = { q: query, defType: 'lucene' } result = connection.paginate(docs.next_page, docs.per_page, 'select', params: params) docs = result.fetch('response').fetch('docs') docs.each do |doc| yield resource_factory.to_resource(object: doc) end end end |
#id ⇒ String
Retrieve the string value for the ID
49 50 51 |
# File 'lib/valkyrie/persistence/solr/queries/find_references_query.rb', line 49 def id resource.id.to_s end |
#query ⇒ String
Generate the Solr join query using the id_ssi field
43 44 45 |
# File 'lib/valkyrie/persistence/solr/queries/find_references_query.rb', line 43 def query "{!join from=#{property}_ssim to=join_id_ssi}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_references_query.rb', line 21 def run enum_for(:each) end |