Sha256: 93c1b6e4379c7f43beb1c42501e7170ab6c452436ca529a04af2182d82bfc7ed
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
module RSolr Dir.glob(File.expand_path("../rsolr/*.rb", __FILE__)).each{|rb_file| require(rb_file)} def self.connect *args opts = args.pop if args.last.is_a?(::Hash) opts ||= {} connection = args.first Client.new connection, opts end # backslash escape characters that have special meaning to Solr query parser # per http://lucene.apache.org/core/4_0_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Escaping_Special_Characters # + - & | ! ( ) { } [ ] ^ " ~ * ? : \ / # see also http://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 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 module Array def self.wrap(object) if object.nil? [] elsif object.respond_to?(:to_ary) object.to_ary || [object] elsif object.is_a? Hash [object] elsif object.is_a? Enumerable object else [object] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rsolr-2.0.0.pre2 | lib/rsolr.rb |