class Riak::Search::Index
A {Riak::Search::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.
Attributes
@!attribute [r] client @return [Riak::Client] the client to operate on the index with
@!attribute [r] name @return [String] the name of the index
Public Class Methods
Initializes an index object, that may or may not exist.
@param [Riak::Client] client the client connected to the Riak
cluster
you wish to operate on
@param [String] name the name of the index
# File lib/riak/search/index.rb, line 22 def initialize(client, name) @client = client @name = name end
Public Instance Methods
Attempt to create this index
@raise [Riak::SearchError::IndexExistsError] if an index with the given
name already exists
# 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
@return [Boolean] does this index exist on Riak
?
# File lib/riak/search/index.rb, line 28 def exists? !!index_data end
@return [Integer] N-value/replication parameter of this index
# File lib/riak/search/index.rb, line 33 def n_val index_data[:n_val] end
Create a {Riak::Search::Query} using this index and client
@param [String] term the query term @param [Hash] options a hash of options to set attributes on the query @return [Riak::Search::Query] a query using this index
# File lib/riak/search/index.rb, line 63 def query(term, options = { }) Riak::Search::Query.new(@client, self, term, options) end
@return [String] schema name of this index
# File lib/riak/search/index.rb, line 38 def schema index_data[:schema] end
Private Instance Methods
# File lib/riak/search/index.rb, line 68 def index_data return @index_data if defined?(@index_data) && @index_data id = nil begin id = @client.backend do |b| b.get_search_index name end.index rescue Riak::ProtobuffsFailedRequest => e return nil if e.not_found? raise e end id = id.first if id.is_a? Array return @index_data = id end