module Mebla
A wrapper for slingshot elastic-search adapter for Mongoid
A wrapper for slingshot elastic-search adapter for Mongoid
A wrapper for slingshot elastic-search adapter for Mongoid
A wrapper for slingshot elastic-search adapter for Mongoid
A wrapper for slingshot elastic-search adapter for Mongoid
A wrapper for slingshot elastic-search adapter for Mongoid
A wrapper for slingshot elastic-search adapter for Mongoid
A wrapper for slingshot elastic-search adapter for Mongoid
A wrapper for slingshot elastic-search adapter for Mongoid
A wrapper for slingshot elastic-search adapter for Mongoid
A wrapper for slingshot elastic-search adapter for Mongoid
A wrapper for slingshot elastic-search adapter for Mongoid
A wrapper for slingshot elastic-search adapter for Mongoid
A wrapper for slingshot elastic-search adapter for Mongoid
Public Class Methods
Configure Mebla
- Example
-
Mebla.configure
do |config|index = "mebla_index" host = "localhost" port = 9200
end
# File lib/mebla.rb, line 80 def self.configure(&block) yield Mebla::Configuration.instance end
Returns Mebla’s context for minipulating the index @return [nil]
# File lib/mebla.rb, line 30 def self.context if @@context.nil? @@mebla_mutex.synchronize do if @@context.nil? @@context = Mebla::Context.new end end end @@context end
Check if elasticsearch is running @return [Boolean]
# File lib/mebla.rb, line 64 def self.elasticsearch? result = Slingshot::Configuration.client.get "#{Slingshot::Configuration.url}/_status" return (result =~ /error/) ? false: true rescue RestClient::Exception false end
Writes out a message to the log file according to the level given @note If no level is given a message of type Logger::UNKNOWN will be written to the log file @param [String] message @param [Symbol] level can be :debug, :warn or :info @return [nil]
# File lib/mebla.rb, line 90 def self.log(message, level = :none) case level when :debug hook = "mebla_debug.mebla" when :warn hook = "mebla_warn.mebla" when :info hook = "mebla_info.mebla" else hook = "mebla_unknown.mebla" end ::ActiveSupport::Notifications. instrument(hook, :message => message) end
Check if mongoid is loaded @return [Boolean]
# File lib/mebla.rb, line 52 def self.mongoid? !defined?(Mongoid).nil? end
Resets the context (reloads Mebla
) @return [nil]
# File lib/mebla.rb, line 44 def self.reset_context! @@mebla_mutex.synchronize do @@context = nil end end
Search
the index @param [String] query a string representing the search query @param [String, Symbol, Array] type_names a string, symbol or array representing the models to be searcheds @return [Mebla::Search]
Search
for all documents with a field ‘title’ with a value ‘Testing Search’-
Mebla.search
“title: Testing Search”
# File lib/mebla.rb, line 114 def self.search(query = "", type_names = nil) Mebla::Search.new(query, type_names) end
Check if slingshot is loaded @return [Boolean]
# File lib/mebla.rb, line 58 def self.slingshot? !defined?(Slingshot).nil? end