Class: SolrCloud::Alias
- Inherits:
-
Collection
- Object
- Collection
- SolrCloud::Alias
- Defined in:
- lib/solr_cloud/alias.rb
Overview
An alias shouldn’t be created directly. Rather, get an existing one with Connection#alias, or from a collection, or create one with Collection#alias_as
Instance Attribute Summary
Attributes inherited from Collection
Instance Method Summary collapse
-
#alias? ⇒ Boolean
An alias is, shockingly, an alias.
-
#collection ⇒ Collection
Get the collection this alias points to.
-
#delete! ⇒ Connection
Delete this alias.
-
#exist? ⇒ Boolean
Does this alias still exist?.
-
#info ⇒ Object
Get basic information on the underlying collection, so inherited methods that use it (e.g., #healthy?) will work.
- #inspect ⇒ Object (also: #to_s)
- #pretty_print(q) ⇒ Object
-
#switch_collection_to(coll) ⇒ Collection
(also: #collection=)
Redefine what collection this alias points to This is equivalent to dropping/re-adding the alias, or calling connection.create_alias with ‘force: true`.
Methods inherited from Collection
#==, #add, #alias_as, #alias_as!, #alias_names, #aliased?, #aliases, #alive?, #commit, #configset, #count, #delete, #get, #get_alias, #has_alias?, #healthy?, #initialize, #post, #put
Constructor Details
This class inherits a constructor from SolrCloud::Collection
Instance Method Details
#alias? ⇒ Boolean
An alias is, shockingly, an alias. Convenience to differentiate aliases from collections.
13 14 15 |
# File 'lib/solr_cloud/alias.rb', line 13 def alias? true end |
#collection ⇒ Collection
Get the collection this alias points to. In real life, Solr will allow an alias to point to more than one collection. Functionality for this might be added at some point
34 35 36 |
# File 'lib/solr_cloud/alias.rb', line 34 def collection connection.alias_map[name].collection end |
#delete! ⇒ Connection
Delete this alias. Will be a no-op if it doesn’t exist.
19 20 21 22 23 |
# File 'lib/solr_cloud/alias.rb', line 19 def delete! return connection unless exist? connection.get("solr/admin/collections", action: "DELETEALIAS", name: name) connection end |
#exist? ⇒ Boolean
Does this alias still exist?
26 27 28 |
# File 'lib/solr_cloud/alias.rb', line 26 def exist? connection.alias_names.include?(name) end |
#info ⇒ Object
Get basic information on the underlying collection, so inherited methods that use it (e.g., #healthy?) will work.
60 61 62 |
# File 'lib/solr_cloud/alias.rb', line 60 def info collection.info end |
#inspect ⇒ Object Also known as: to_s
64 65 66 |
# File 'lib/solr_cloud/alias.rb', line 64 def inspect "<#{self.class} '#{name}' (alias of '#{collection.name}')>" end |
#pretty_print(q) ⇒ Object
70 71 72 |
# File 'lib/solr_cloud/alias.rb', line 70 def pretty_print(q) q.text inspect end |
#switch_collection_to(coll) ⇒ Collection Also known as: collection=
Redefine what collection this alias points to This is equivalent to dropping/re-adding the alias, or calling connection.create_alias with ‘force: true`
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/solr_cloud/alias.rb', line 42 def switch_collection_to(coll) collect_name = case coll when String coll when Collection coll.name else raise "Alias#switch_collection_to only takes a name(string) or a collection, not '#{coll}'" end raise NoSuchCollectionError unless connection.has_collection?(collect_name) connection.create_alias(name: name, collection_name: collect_name, force: true) end |