Class: Valkyrie::Persistence::Solr::Queries::FindOrderedReferencesQuery
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::Solr::Queries::FindOrderedReferencesQuery
- Defined in:
- lib/valkyrie/persistence/solr/queries/find_ordered_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
- #docs ⇒ Object
- #each ⇒ Object
- #id ⇒ Object
-
#initialize(resource:, property:, connection:, resource_factory:) ⇒ FindOrderedReferencesQuery
constructor
A new instance of FindOrderedReferencesQuery.
- #property_values ⇒ Object
- #query ⇒ Object
- #run ⇒ Object
- #unordered_members ⇒ Object
Constructor Details
#initialize(resource:, property:, connection:, resource_factory:) ⇒ FindOrderedReferencesQuery
Returns a new instance of FindOrderedReferencesQuery.
7 8 9 10 11 12 |
# File 'lib/valkyrie/persistence/solr/queries/find_ordered_references_query.rb', line 7 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_ordered_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_ordered_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_ordered_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_ordered_references_query.rb', line 6 def resource_factory @resource_factory end |
Instance Method Details
#docs ⇒ Object
31 32 33 34 35 36 |
# File 'lib/valkyrie/persistence/solr/queries/find_ordered_references_query.rb', line 31 def docs = { q: query, rows: 1_000_000_000 } [:defType] = 'lucene' result = connection.get("select", params: ) result.fetch('response').fetch('docs') end |
#each ⇒ Object
18 19 20 21 22 23 |
# File 'lib/valkyrie/persistence/solr/queries/find_ordered_references_query.rb', line 18 def each # map them off of the property to fix solr's deduplication property_values.map { |id| unordered_members.find { |member| member.id == id } } .reject(&:nil?).each do |value| yield value end end |
#id ⇒ Object
46 47 48 |
# File 'lib/valkyrie/persistence/solr/queries/find_ordered_references_query.rb', line 46 def id resource.id.to_s end |
#property_values ⇒ Object
38 39 40 |
# File 'lib/valkyrie/persistence/solr/queries/find_ordered_references_query.rb', line 38 def property_values Array.wrap(resource[property]) end |
#query ⇒ Object
42 43 44 |
# File 'lib/valkyrie/persistence/solr/queries/find_ordered_references_query.rb', line 42 def query "{!join from=#{property}_ssim to=join_id_ssi}id:#{id}" end |
#run ⇒ Object
14 15 16 |
# File 'lib/valkyrie/persistence/solr/queries/find_ordered_references_query.rb', line 14 def run enum_for(:each) end |
#unordered_members ⇒ Object
25 26 27 28 29 |
# File 'lib/valkyrie/persistence/solr/queries/find_ordered_references_query.rb', line 25 def unordered_members @unordered_members ||= docs.map do |doc| resource_factory.to_resource(object: doc) end end |