Class: Hyrax::SolrQueryBuilderService Deprecated

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/solr_query_builder_service.rb

Overview

Deprecated.

This class is being replaced by Hyrax::SolrQueryService.

Methods in this class are from/based on ActiveFedora::SolrQueryBuilder

See Also:

Class Method Summary collapse

Class Method Details

.construct_query(field_pairs, join_with = default_join_with, type = 'field') ⇒ String

Deprecated.

Construct a solr query from a list of pairs (e.g. [field name, values])

Examples:

construct_query([['library_id_ssim', '123'], ['owner_ssim', 'Fred']])
# => "_query_:\"{!field f=library_id_ssim}123\" AND _query_:\"{!field f=owner_ssim}Fred\""

Parameters:

  • field_pairs (Hash)

    a list of pairs of property name and values

  • join_with (String) (defaults to: default_join_with)

    the value we're joining the clauses with (default: ' AND ')

  • type (String) (defaults to: 'field')

    of query to run. Either 'raw' or 'field' (default: 'field')

Returns:

  • (String)

    a solr query


38
39
40
41
42
43
44
# File 'app/services/hyrax/solr_query_builder_service.rb', line 38

def construct_query(field_pairs, join_with = default_join_with, type = 'field')
  Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0.  " \
                   "Instead, use 'Hyrax::SolrQueryService.new.with_field_pairs'.")
  Hyrax::SolrQueryService.new.with_field_pairs(field_pairs: field_pairs,
                                               join_with: join_with,
                                               type: type).build
end

.construct_query_for_ids(id_array) ⇒ String

Deprecated.

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

Examples:

construct_query_for_ids(['a1', 'b2'])
# => "{!terms f=id}a1,b2"

Parameters:

  • id_array (Array)

    the ids that you want included in the query

Returns:

  • (String)

    a solr query


21
22
23
24
25
26
27
# File 'app/services/hyrax/solr_query_builder_service.rb', line 21

def construct_query_for_ids(id_array)
  Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0.  " \
                   "Instead, use 'Hyrax::SolrQueryService.new.with_ids'.")
  ids = id_array.reject(&:blank?)
  return "id:NEVER_USE_THIS_ID" if ids.empty?
  Hyrax::SolrQueryService.new.with_ids(ids: id_array).build
end

.construct_query_for_model(model, field_pairs, join_with = default_join_with, type = 'field') ⇒ String

Deprecated.

Construct a solr query from a list of pairs (e.g. [field name, values]) including the model (e.g. Collection, Monograph)

Examples:

construct_query(Collection, [['library_id_ssim', '123'], ['owner_ssim', 'Fred']])
# => "_query_:\"{!field f=has_model_ssim}Collection\" AND _query_:\"{!field f=library_id_ssim}123\" AND _query_:\"{!field f=owner_ssim}Fred\""

Parameters:

  • model (Class)

    class

  • field_pairs (Hash)

    a list of pairs of property name and values

  • join_with (String) (defaults to: default_join_with)

    the value we're joining the clauses with (default: ' AND ')

  • type (String) (defaults to: 'field')

    of query to run. Either 'raw' or 'field' (default: 'field')

Returns:

  • (String)

    a solr query


63
64
65
66
67
68
69
70
# File 'app/services/hyrax/solr_query_builder_service.rb', line 63

def construct_query_for_model(model, field_pairs, join_with = default_join_with, type = 'field')
  Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0.  " \
                   "Instead, use 'Hyrax::SolrQueryService.new.with_model'.")
  field_pairs["has_model_ssim"] = model.to_s
  Hyrax::SolrQueryService.new.with_field_pairs(field_pairs: field_pairs,
                                               join_with: join_with,
                                               type: type).build
end

.default_join_withObject

Deprecated.

47
48
49
50
51
# File 'app/services/hyrax/solr_query_builder_service.rb', line 47

def default_join_with
  Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0.  " \
                   "There will not be a replacement for this method. See Hyrax::SolrQueryService which is replacing this class.")
  ' AND '
end