Module: ActiveFedora::SolrQueryBuilder
- Extended by:
- Deprecation
- Defined in:
- lib/active_fedora/solr_query_builder.rb
Class Method Summary collapse
-
.construct_query(field_pairs, join_with = ' AND ') ⇒ 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.
-
.construct_query_for_rel(field_pairs, join_with = ' AND ') ⇒ Object
Create a query with a clause for each key, value.
-
.raw_query(key, value) ⇒ Object
Create a raw query clause suitable for sending to solr as an fq element.
- .solr_name(*args) ⇒ Object deprecated Deprecated.
Class Method Details
.construct_query(field_pairs, join_with = ' AND ') ⇒ String
Construct a solr query from a list of pairs (e.g. [field name, values])
50 51 52 |
# File 'lib/active_fedora/solr_query_builder.rb', line 50 def construct_query(field_pairs, join_with = ' AND ') pairs_to_clauses(field_pairs).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 'lib/active_fedora/solr_query_builder.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=#{ActiveFedora.id_field}}#{ids.join(',')}" end |
.construct_query_for_rel(field_pairs, join_with = ' AND ') ⇒ Object
Create a query with a clause for each key, value
38 39 40 41 |
# File 'lib/active_fedora/solr_query_builder.rb', line 38 def construct_query_for_rel(field_pairs, join_with = ' AND ') field_pairs = field_pairs.to_a if field_pairs.is_a? Hash construct_query(property_values_to_solr(field_pairs), join_with) end |
.raw_query(key, value) ⇒ Object
Create a raw query clause suitable for sending to solr as an fq element
19 20 21 22 |
# File 'lib/active_fedora/solr_query_builder.rb', line 19 def raw_query(key, value) Deprecation.warn(ActiveFedora::SolrQueryBuilder, 'ActiveFedora::SolrQueryBuilder.raw_query is deprecated and will be removed in ActiveFedora 10.0. Use .construct_query instead.') "_query_:\"{!raw f=#{key}}#{value.gsub('"', '\"')}\"" end |
.solr_name(*args) ⇒ Object
25 26 27 28 |
# File 'lib/active_fedora/solr_query_builder.rb', line 25 def solr_name(*args) Deprecation.warn(ActiveFedora::SolrQueryBuilder, 'ActiveFedora::SolrQueryBuilder.solr_name is deprecated and will be removed in ActiveFedora 10.0. Use ActiveFedora.index_field_mapper.solr_name instead.') ActiveFedora.index_field_mapper.solr_name(*args) end |