Module: RSolr

Extended by:
Char
Defined in:
lib/rsolr.rb,
lib/rsolr/version.rb

Defined Under Namespace

Modules: Char, Error, Response, Uri, Xml Classes: Client, Connection, HashWithResponse

Constant Summary collapse

VERSION =
"1.0.12"

Class Method Summary collapse

Methods included from Char

escape

Class Method Details

.connect(*args) ⇒ Object



5
6
7
8
9
# File 'lib/rsolr.rb', line 5

def self.connect *args
  driver = Class === args[0] ? args[0] : RSolr::Connection
  opts = Hash === args[-1] ? args[-1] : {}
  Client.new driver.new, opts
end

.solr_escape(str) ⇒ String

Returns:

  • (String)

    str with special chars preceded by a backslash



20
21
22
23
24
# File 'lib/rsolr.rb', line 20

def self.solr_escape(str)
  # note that the gsub will parse the escaped backslashes, as will the ruby code sending the query to Solr 
  # so the result sent to Solr is ultimately a single backslash in front of the particular character 
  str.gsub(/([+\-&|!\(\)\{\}\[\]\^"~\*\?:\\\/])/, '\\\\\1')
end

.versionObject



4
5
6
# File 'lib/rsolr/version.rb', line 4

def self.version
  VERSION
end