Module: RSolr

Defined in:
lib/rsolr.rb,
lib/rsolr/field.rb,
lib/rsolr/version.rb,
lib/rsolr/document.rb,
lib/rsolr/generator.rb

Defined Under Namespace

Modules: Array, Char, Error, JSON, Response, Uri, Xml Classes: Client, DateField, DateTimeField, Document, DocumentField, Field, Generator, HashWithResponse, TimeField

Constant Summary collapse

VERSION =
"2.6.0"

Class Method Summary collapse

Class Method Details

.connect(*args) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/rsolr.rb', line 16

def self.connect *args
  opts = args.pop if args.last.is_a?(::Hash)
  opts ||= {}

  connection = args.first

  Client.new connection, opts
end

.solr_escape(str) ⇒ String

Returns:

  • (String)

    str with special chars preceded by a backslash



31
32
33
34
35
# File 'lib/rsolr.rb', line 31

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