Class: Riak::Search::Schema
Overview
A schema is a Riak Search 2 concept that describes how to index documents. They’re implemented as a standard Solr XML schema.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of the schema.
Instance Method Summary collapse
-
#content ⇒ String
The XML content of this schema.
- #create!(content) ⇒ Object
-
#exists? ⇒ Boolean
Does this schema exist on Riak?.
-
#initialize(client, name) ⇒ Schema
constructor
Initializes a schema object, that may or may not exist.
Constructor Details
#initialize(client, name) ⇒ Schema
Initializes a schema object, that may or may not exist.
16 17 18 19 |
# File 'lib/riak/search/schema.rb', line 16 def initialize(client, name) @client = client @name = name end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name of the schema.
9 10 11 |
# File 'lib/riak/search/schema.rb', line 9 def name @name end |
Instance Method Details
#content ⇒ String
Returns the XML content of this schema.
27 28 29 |
# File 'lib/riak/search/schema.rb', line 27 def content schema_data.content end |
#create!(content) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/riak/search/schema.rb', line 34 def create!(content) fail Riak::SearchError::SchemaExistsError.new name if exists? @client.backend do |b| b.create_search_schema name, content end @schema_data = nil true end |
#exists? ⇒ Boolean
Returns does this schema exist on Riak?.
22 23 24 |
# File 'lib/riak/search/schema.rb', line 22 def exists? !!schema_data end |