class ActiveFedora::SolrService
def add(doc, params = {})
-
params
(Hash
) -- -
doc
(Hash
) -- the document to index
def add(doc, params = {}) SolrService.instance.conn.add(doc, params: params) end
def class_from_solr_document(hit, opts = {})
def class_from_solr_document(hit, opts = {}) Deprecation.warn SolrService, "SolrService.class_from_solr_document is deprecated. Use QueryResultBuilder.class_from_solr_document instead. This will be removed in active-fedora 10.0" QueryResultBuilder.class_from_solr_document(hit, opts) end
def classes_from_solr_document(hit, opts = {})
def classes_from_solr_document(hit, opts = {}) Deprecation.warn SolrService, "SolrService.classes_from_solr_document is deprecated. Use QueryResultBuilder.classes_from_solr_document instead. This will be removed in active-fedora 10.0" QueryResultBuilder.classes_from_solr_document(hit, opts) end
def commit
def commit SolrService.instance.conn.commit end
def construct_query_for_ids(id_array)
-
id_array
(Array
) -- the ids that you want included in the query
def construct_query_for_ids(id_array) Deprecation.warn SolrService, "SolrService.construct_query_for_ids is deprecated. Use SolrQueryBuilder.construct_query_for_ids instead. This will be removed in active-fedora 10.0" SolrQueryBuilder.construct_query_for_ids(id_array) end
def construct_query_for_pids(id_array)
def construct_query_for_pids(id_array) Deprecation.warn SolrService, "construct_query_for_pids is deprecated and will be removed in active-fedora 10.0" SolrQueryBuilder.construct_query_for_ids(id_array) end
def construct_query_for_rel(field_pairs, join_with = 'AND')
-
join_with
(String
) -- ('AND') the value we're joining the clauses with -
field_pairs
(Hash, Array
) -- key is the predicate, value is the target_uri>
def construct_query_for_rel(field_pairs, join_with = 'AND') Deprecation.warn SolrService, "SolrService.construct_query_for_rel is deprecated. Use SolrQueryBuilder.construct_query_for_rel instead. This will be removed in active-fedora 10.0" SolrQueryBuilder.construct_query_for_rel(field_pairs, join_with) end
def count(query, args={})
-
(Integer)
- number of records matching
Parameters:
-
args
(Hash
) -- arguments to pass through to `args' param of SolrService.query (note that :rows will be overwritten to 0) -
query
(String
) -- a solr query
def count(query, args={}) args = args.merge(:raw=>true, :rows=>0) SolrService.query(query, args)['response']['numFound'].to_i end
def delete(id)
def delete(id) SolrService.instance.conn.delete_by_id(id, params: {'softCommit' => true}) end
def initialize(host, args)
def initialize(host, args) host = 'http://localhost:8080/solr' unless host args = {read_timeout: 120, open_timeout: 120}.merge(args.dup) args.merge!(url: host) @conn = RSolr.connect args end
def instance
def instance # Register Solr unless Thread.current[:solr_service] register(ActiveFedora.solr_config[:url]) end raise SolrNotInitialized unless Thread.current[:solr_service] Thread.current[:solr_service] end
def lazy_reify_solr_results(solr_results, opts = {})
def lazy_reify_solr_results(solr_results, opts = {}) Deprecation.warn SolrService, "SolrService.lazy_reify_solr_results is deprecated. Use QueryResultBuilder.lazy_reify_solr_results instead. This will be removed in active-fedora 10.0" QueryResultBuilder.lazy_reify_solr_results(solr_results, opts) end
def query(query, args={})
def query(query, args={}) raw = args.delete(:raw) args = args.merge(:q=>query, :qt=>'standard') result = SolrService.instance.conn.get('select', :params=>args) return result if raw result['response']['docs'] end
def raw_query(key, value)
-
value
(String
) -- -
key
(String
) --
def raw_query(key, value) Deprecation.warn SolrService, "SolrService.raw_query is deprecated. Use SolrQueryBuilder.raw_query instead. This will be removed in active-fedora 10.0" SolrQueryBuilder.raw_query(key, value) end
def register(host=nil, args={})
def register(host=nil, args={}) Thread.current[:solr_service] = new(host, args) end
def reify_solr_result(hit, opts = {})
def reify_solr_result(hit, opts = {}) Deprecation.warn SolrService, "SolrService.reify_solr_result is deprecated. Use QueryResultBuilder.reify_solr_result instead. This will be removed in active-fedora 10.0" QueryResultBuilder.reify_solr_result(hit, opts) end
def reify_solr_results(solr_results, opts = {})
def reify_solr_results(solr_results, opts = {}) Deprecation.warn SolrService, "SolrService.reify_solr_results is deprecated. Use QueryResultBuilder.reify_solr_results instead. This will be removed in active-fedora 10.0" QueryResultBuilder.reify_solr_results(solr_results, opts) end
def reset!
def reset! Thread.current[:solr_service] = nil end
def solr_name(*args)
def solr_name(*args) Deprecation.warn SolrService, "SolrService.solr_name is deprecated. Use SolrQueryBuilder.solr_name instead. This will be removed in active-fedora 10.0" SolrQueryBuilder.solr_name(*args) end