Sha256: 6d763c932f36a53d4306036192291cfeb0d107d603a158a9d2f7696e59465c4b
Contents?: true
Size: 892 Bytes
Versions: 22
Compression:
Stored size: 892 Bytes
Contents
require 'faraday' require 'json' module SolrWrapper # Solr REST API client to get status information class Client attr_reader :url def initialize(url) @url = url end # Check if a core or collection exists def exists?(core_or_collection_name) collection?(core_or_collection_name) || core?(core_or_collection_name) end private def collection?(name) response = conn.get('admin/collections?action=LIST&wt=json') data = JSON.parse(response.body) return if data['error'] && data['error']['msg'] == 'Solr instance is not running in SolrCloud mode.' data['collections'].include? name end def core?(name) response = conn.get('admin/cores?action=STATUS&wt=json&core=' + name) !JSON.parse(response.body)['status'][name].empty? end def conn @conn ||= Faraday.new(url: url) end end end
Version data entries
22 entries across 22 versions & 1 rubygems