Module: Solr

Extended by:
Cloud::HelperMethods, Commands, HelperMethods, MasterSlave::HelperMethods
Defined in:
lib/solr/query/request/boosting/geodist_function.rb,
lib/solr.rb,
lib/solr/testing.rb,
lib/solr/version.rb,
lib/solr/commands.rb,
lib/solr/document.rb,
lib/solr/response.rb,
lib/solr/connection.rb,
lib/solr/configuration.rb,
lib/solr/query/handler.rb,
lib/solr/query/request.rb,
lib/solr/commit/request.rb,
lib/solr/delete/request.rb,
lib/solr/helper_methods.rb,
lib/solr/query/response.rb,
lib/solr/request/runner.rb,
lib/solr/response/header.rb,
lib/solr/response/parser.rb,
lib/solr/indexing/request.rb,
lib/solr/indexing/document.rb,
lib/solr/support/url_helper.rb,
lib/solr/cloud/configuration.rb,
lib/solr/data_import/request.rb,
lib/solr/document_collection.rb,
lib/solr/query/request/facet.rb,
lib/solr/response/solr_error.rb,
lib/solr/cloud/helper_methods.rb,
lib/solr/query/request/filter.rb,
lib/solr/request/http_request.rb,
lib/solr/response/http_status.rb,
lib/solr/query/request/sorting.rb,
lib/solr/query/response/parser.rb,
lib/solr/support/schema_helper.rb,
lib/solr/query/request/boosting.rb,
lib/solr/query/request/grouping.rb,
lib/solr/errors/solr_query_error.rb,
lib/solr/query/request/or_filter.rb,
lib/solr/support/hash_extensions.rb,
lib/solr/core_configuration/field.rb,
lib/solr/query/request/and_filter.rb,
lib/solr/query/request/field_list.rb,
lib/solr/query/request/geo_filter.rb,
lib/solr/query/request/spellcheck.rb,
lib/solr/errors/zookeeper_required.rb,
lib/solr/query/response/spellcheck.rb,
lib/solr/support/connection_helper.rb,
lib/solr/support/string_extensions.rb,
lib/solr/cloud/zookeeper_connection.rb,
lib/solr/master_slave/configuration.rb,
lib/solr/query/http_request_builder.rb,
lib/solr/query/response/facet_value.rb,
lib/solr/errors/ambiguous_core_error.rb,
lib/solr/grouped_document_collection.rb,
lib/solr/master_slave/helper_methods.rb,
lib/solr/query/request/sorting/field.rb,
lib/solr/query/response/field_facets.rb,
lib/solr/query/request/boost_magnitude.rb,
lib/solr/query/request/edismax_adapter.rb,
lib/solr/core_configuration/core_config.rb,
lib/solr/query/request/field_with_boost.rb,
lib/solr/query/request/sorting/function.rb,
lib/solr/cloud/collections_state_manager.rb,
lib/solr/query/request/shards_preference.rb,
lib/solr/request/node_selection_strategy.rb,
lib/solr/core_configuration/dynamic_field.rb,
lib/solr/errors/no_active_solr_nodes_error.rb,
lib/solr/errors/solr_url_not_defined_error.rb,
lib/solr/errors/solr_connection_failed_error.rb,
lib/solr/master_slave/nodes_gray_list/disabled.rb,
lib/solr/core_configuration/core_config_builder.rb,
lib/solr/master_slave/nodes_gray_list/in_memory.rb,
lib/solr/errors/could_not_detect_endpoint_in_url.rb,
lib/solr/request/default_node_selection_strategy.rb,
lib/solr/query/request/boosting/ln_function_boost.rb,
lib/solr/errors/could_not_infer_implicit_core_name.rb,
lib/solr/query/request/shards_preferences/property.rb,
lib/solr/query/request/boosting/scale_function_boost.rb,
lib/solr/query/request/boosting/exists_boost_function.rb,
lib/solr/request/cloud/leader_node_selection_strategy.rb,
lib/solr/query/request/boosting/phrase_proximity_boost.rb,
lib/solr/query/request/boosting/dictionary_boost_function.rb,
lib/solr/query/request/boosting/ranking_field_boost_function.rb,
lib/solr/request/master_slave/master_node_selection_strategy.rb,
lib/solr/query/request/boosting/field_value_match_boost_function.rb,
lib/solr/query/request/boosting/recent_field_value_boost_function.rb,
lib/solr/request/cloud/first_shard_leader_node_selection_strategy.rb,
lib/solr/query/request/boosting/field_value_less_than_boost_function.rb,
lib/solr/query/request/boosting/numeric_field_value_match_boost_function.rb,
lib/solr/query/request/boosting/textual_field_value_match_boost_function.rb

Overview

Defined Under Namespace

Modules: Cloud, Commands, Commit, CoreConfiguration, DataImport, Delete, Errors, HelperMethods, Indexing, MasterSlave, Query, Request, Support, Testing Classes: Configuration, Connection, Document, DocumentCollection, GroupedDocumentCollection, Response

Constant Summary collapse

CURRENT_CORE_CONFIG_VARIABLE_NAME =
:solrb_current_core_config
SOLR_NODE_URL_OVERRIDE_CONFIG =
:solrb_node_url_override_config
VERSION =
'0.2.9'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from HelperMethods

active_nodes_for

Methods included from MasterSlave::HelperMethods

enable_master_slave!, master_slave_active_nodes_for, master_slave_enabled?

Methods included from Cloud::HelperMethods

cloud_active_nodes_for, cloud_enabled?, enable_solr_cloud!, leader_replica_node_for, shards_for

Methods included from Commands

commit, data_import, delete_by_id, delete_by_query

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



33
34
35
# File 'lib/solr.rb', line 33

def configuration
  @configuration
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



37
38
39
40
41
42
43
44
45
46
# File 'lib/solr.rb', line 37

def configure
  yield configuration
  configuration.validate!
  if configuration.zookeeper_url
    enable_solr_cloud!
  elsif configuration.master_url
    enable_master_slave!
  end
  configuration
end

.current_core_configObject



48
49
50
# File 'lib/solr.rb', line 48

def current_core_config
  Thread.current[CURRENT_CORE_CONFIG_VARIABLE_NAME] || Solr.configuration.default_core_config
end

.instrument(name:, data: {}) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/solr.rb', line 76

def instrument(name:, data: {})
  if defined? ActiveSupport::Notifications
    # Create a copy of data to avoid modifications on the original object by rails
    # https://github.com/rails/rails/blob/master/activesupport/lib/active_support/notifications.rb#L66-L70
    ActiveSupport::Notifications.instrument(name, data.dup) do
      yield if block_given?
    end
  else
    yield if block_given?
  end
end

.node_url_overrideObject



68
69
70
# File 'lib/solr.rb', line 68

def node_url_override
  Thread.current[SOLR_NODE_URL_OVERRIDE_CONFIG]
end

.solr_url(path = '') ⇒ Object



72
73
74
# File 'lib/solr.rb', line 72

def solr_url(path = '')
  Solr::Support::UrlHelper.solr_url(path)
end

.with_core(core) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/solr.rb', line 52

def with_core(core)
  core_config = Solr.configuration.core_config_by_name(core)
  old_core_config = Thread.current[CURRENT_CORE_CONFIG_VARIABLE_NAME]
  Thread.current[CURRENT_CORE_CONFIG_VARIABLE_NAME] = core_config
  yield
ensure
  Thread.current[CURRENT_CORE_CONFIG_VARIABLE_NAME] = old_core_config
end

.with_node_url(url) ⇒ Object



61
62
63
64
65
66
# File 'lib/solr.rb', line 61

def with_node_url(url)
  Thread.current[SOLR_NODE_URL_OVERRIDE_CONFIG] = url
  yield
ensure
  Thread.current[SOLR_NODE_URL_OVERRIDE_CONFIG] = nil
end