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.
30 31 32 33 |
# File 'lib/riak/search/schema.rb', line 30 def initialize(client, name) @client = client @name = name end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name of the schema.
23 24 25 |
# File 'lib/riak/search/schema.rb', line 23 def name @name end |
Instance Method Details
#content ⇒ String
Returns the XML content of this schema.
41 42 43 |
# File 'lib/riak/search/schema.rb', line 41 def content schema_data.content end |
#create!(content) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/riak/search/schema.rb', line 48 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?.
36 37 38 |
# File 'lib/riak/search/schema.rb', line 36 def exists? !!schema_data end |