module RSolr

Constants

VERSION

Public Class Methods

connect(*args) click to toggle source
# 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) click to toggle source

backslash escape characters that have special meaning to Solr query parser per lucene.apache.org/core/4_0_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Escaping_Special_Characters

+ - & | ! ( ) { } [ ] ^ " ~ * ? : \ /

see also svn.apache.org/repos/asf/lucene/dev/tags/lucene_solr_4_9_1/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java

escapeQueryChars method

@return [String] str with special chars preceded by a backslash

# 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
version() click to toggle source
# File lib/rsolr/version.rb, line 4
def self.version
  VERSION
end