Class: Hyrax::SolrQueryBuilderService
- Inherits:
-
Object
- Object
- Hyrax::SolrQueryBuilderService
- Defined in:
- app/services/hyrax/solr_query_builder_service.rb
Overview
Methods in this class are from/based on ActiveFedora::SolrQueryBuilder
Class Method Summary collapse
-
.construct_query(field_pairs, join_with = default_join_with, type = 'field') ⇒ String
Construct a solr query from a list of pairs (e.g. [field name, values]).
-
.construct_query_for_ids(id_array) ⇒ Object
Construct a solr query for a list of ids This is used to get a solr response based on the list of ids in an object’s RELS-EXT relationhsips If the id_array is empty, defaults to a query of “id:NEVER_USE_THIS_ID”, which will return an empty solr response.
- .default_join_with ⇒ Object
Class Method Details
.construct_query(field_pairs, join_with = default_join_with, type = 'field') ⇒ String
Construct a solr query from a list of pairs (e.g. [field name, values])
24 25 26 27 28 29 |
# File 'app/services/hyrax/solr_query_builder_service.rb', line 24 def construct_query(field_pairs, join_with = default_join_with, type = 'field') clauses = pairs_to_clauses(field_pairs, type) return "" if clauses.count.zero? return clauses.first if clauses.count == 1 "(#{clauses.join(join_with)})" end |
.construct_query_for_ids(id_array) ⇒ Object
Construct a solr query for a list of ids This is used to get a solr response based on the list of ids in an object’s RELS-EXT relationhsips If the id_array is empty, defaults to a query of “id:NEVER_USE_THIS_ID”, which will return an empty solr response
10 11 12 13 14 |
# File 'app/services/hyrax/solr_query_builder_service.rb', line 10 def construct_query_for_ids(id_array) ids = id_array.reject(&:blank?) return "id:NEVER_USE_THIS_ID" if ids.empty? "{!terms f=#{Hyrax.config.id_field}}#{ids.join(',')}" end |
.default_join_with ⇒ Object
31 32 33 |
# File 'app/services/hyrax/solr_query_builder_service.rb', line 31 def default_join_with ' AND ' end |