Module: Solr::Support::UrlHelper
- Included in:
- Request::Runner
- Defined in:
- lib/solr/support/url_helper.rb
Class Method Summary collapse
- .build_request_url(url:, path:, url_params: {}) ⇒ Object
- .core_name_from_url(url) ⇒ Object
- .core_url ⇒ Object
- .current_core ⇒ Object
- .solr_cloud_or_master_slave_url ⇒ Object
- .solr_endpoint_from_url(url) ⇒ Object
- .solr_url(path, url_params: {}) ⇒ Object
Class Method Details
.build_request_url(url:, path:, url_params: {}) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/solr/support/url_helper.rb', line 13 def build_request_url(url:, path:, url_params: {}) action_url = File.join(url, path).chomp('/') full_uri = Addressable::URI.parse(action_url) full_uri.query_values = url_params if url_params && url_params.any? full_uri end |
.core_name_from_url(url) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/solr/support/url_helper.rb', line 37 def core_name_from_url(url) full_solr_core_uri = URI.parse(url) core_name = full_solr_core_uri.path.gsub('/solr', '').delete('/') if !core_name || core_name == '' raise Solr::Errors::CouldNotInferImplicitCoreName end core_name end |
.core_url ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/solr/support/url_helper.rb', line 20 def core_url if Solr.cloud_enabled? || Solr.master_slave_enabled? solr_cloud_or_master_slave_url else current_core.uri end end |
.current_core ⇒ Object
33 34 35 |
# File 'lib/solr/support/url_helper.rb', line 33 def current_core Solr.current_core_config end |
.solr_cloud_or_master_slave_url ⇒ Object
28 29 30 31 |
# File 'lib/solr/support/url_helper.rb', line 28 def solr_cloud_or_master_slave_url url = Solr.active_nodes_for(collection: current_core.name.to_s).first File.join(url, current_core.name.to_s) end |
.solr_endpoint_from_url(url) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/solr/support/url_helper.rb', line 48 def solr_endpoint_from_url(url) solr_endpoint = url[/(\A.+\/solr)/] if !solr_endpoint || solr_endpoint == '' raise Solr::Errors::CouldNotDetectEndpointInUrl end solr_endpoint end |
.solr_url(path, url_params: {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/solr/support/url_helper.rb', line 6 def solr_url(path, url_params: {}) full_url = File.join(core_url, path) full_uri = Addressable::URI.parse(full_url) full_uri.query_values = url_params if url_params.any? full_uri end |