Class: Riak::Search::Index
Overview
A Index is how Solr finds documents in Riak Search 2. A bucket or bucket type property must be configured to use the index in order for new and updated documents to be indexed and searchable.
Instance Attribute Summary collapse
-
#client ⇒ Riak::Client
readonly
The client to operate on the index with.
-
#name ⇒ String
readonly
The name of the index.
Instance Method Summary collapse
-
#create!(schema = nil, n_val = nil, timeout = nil) ⇒ Object
Attempt to create this index.
-
#exists? ⇒ Boolean
Does this index exist on Riak?.
-
#initialize(client, name) ⇒ Index
constructor
Initializes an index object, that may or may not exist.
-
#n_val ⇒ Integer
N-value/replication parameter of this index.
-
#query(term, options = { }) ⇒ Riak::Search::Query
Create a Query using this index and client.
-
#schema ⇒ String
Schema name of this index.
Constructor Details
#initialize(client, name) ⇒ Index
Initializes an index object, that may or may not exist.
22 23 24 25 |
# File 'lib/riak/search/index.rb', line 22 def initialize(client, name) @client = client @name = name end |
Instance Attribute Details
#client ⇒ Riak::Client (readonly)
Returns the client to operate on the index with.
15 16 17 |
# File 'lib/riak/search/index.rb', line 15 def client @client end |
#name ⇒ String (readonly)
Returns the name of the index.
11 12 13 |
# File 'lib/riak/search/index.rb', line 11 def name @name end |
Instance Method Details
#create!(schema = nil, n_val = nil, timeout = nil) ⇒ Object
Attempt to create this index
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/riak/search/index.rb', line 46 def create!(schema = nil, n_val = nil, timeout = nil) raise Riak::SearchError::IndexExistsError.new name if exists? @client.backend do |b| b.create_search_index name, schema, n_val, timeout end @index_data = nil true end |
#exists? ⇒ Boolean
Returns does this index exist on Riak?.
28 29 30 |
# File 'lib/riak/search/index.rb', line 28 def exists? !!index_data end |
#n_val ⇒ Integer
Returns N-value/replication parameter of this index.
33 34 35 |
# File 'lib/riak/search/index.rb', line 33 def n_val index_data[:n_val] end |
#query(term, options = { }) ⇒ Riak::Search::Query
Create a Query using this index and client
63 64 65 |
# File 'lib/riak/search/index.rb', line 63 def query(term, = { }) Riak::Search::Query.new(@client, self, term, ) end |
#schema ⇒ String
Returns schema name of this index.
38 39 40 |
# File 'lib/riak/search/index.rb', line 38 def schema index_data[:schema] end |