Module: AWSCloudSearch

Defined in:
lib/aws_cloud_search.rb,
lib/aws_cloud_search/version.rb,
lib/aws_cloud_search/document.rb,
lib/aws_cloud_search/exceptions.rb,
lib/aws_cloud_search/cloud_search.rb,
lib/aws_cloud_search/document_batch.rb,
lib/aws_cloud_search/search_request.rb,
lib/aws_cloud_search/search_response.rb,
lib/aws_cloud_search/document_batcher.rb,
lib/aws_cloud_search/cloud_search_config.rb

Defined Under Namespace

Classes: AwsCloudSearchError, BandwidthLimitExceeded, CloudSearch, CloudSearchConfig, Document, DocumentBatch, DocumentBatcher, HttpClientError, HttpCodeResponseMiddleware, HttpServerError, IncorrectFieldTypeInMatchExpression, InvalidFieldOrRankAliasInRankParameter, InvalidMatchExpression, RequestTimeout, SearchRequest, SearchResponse, UndefinedField, UnexpectedHTTPException, UnknownFieldInMatchExpression, WildcardTermLimit

Constant Summary collapse

API_VERSION =
"2011-02-01"
INVALID_CHAR_XML10 =

AWS CloudSearch only allows XML 1.0 valid characters

/[^\u0009\u000a\u000d\u0020-\uD7FF\uE000-\uFFFD]/m
VERSION =
"0.0.4.pre"

Class Method Summary collapse

Class Method Details

.configuration_urlObject


30
31
32
# File 'lib/aws_cloud_search.rb', line 30

def self.configuration_url
  "https://cloudsearch.us-east-1.amazonaws.com"
end

.create_connection(url, aws_access_key_id = nil, aws_secret_access_key = nil) ⇒ Object

Initialize the module


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/aws_cloud_search.rb', line 38

def self.create_connection(url, aws_access_key_id=nil, aws_secret_access_key=nil)
  connection = Faraday.new url do |builder|
    builder.use AWSCloudSearch::HttpCodeResponseMiddleware
    builder.use FaradayMiddleware::EncodeJson
    builder.use FaradayMiddleware::ParseJson
    builder.adapter Faraday.default_adapter

    # for future reference
    #conn.request :json, :content_type => /\bjson$/
    #conn.response :json, :content_type => /\bjson$/
    #conn.adapter Faraday.default_adapter
  end
  connection.headers['User-Agent'] = "AWSCloudSearch-Ruby-Client/#{VERSION}"
  connection
end

.document_url(domain, region = "us-east-1") ⇒ Object


26
27
28
# File 'lib/aws_cloud_search.rb', line 26

def self.document_url(domain, region="us-east-1")
  "http://doc-#{domain}.#{region}.cloudsearch.amazonaws.com"
end

.escape(str) ⇒ Object

Escape single-quote and backslash chars in the str so that the resulting string is suitable as a query argument.


56
57
58
59
# File 'lib/aws_cloud_search.rb', line 56

def self.escape(str)
  return str if (str.nil? or not str.is_a? String)
  str.gsub(/\\/, "\\\\\\").gsub(/'/, "\\\\'")
end

.search_url(domain, region = "us-east-1") ⇒ Object


22
23
24
# File 'lib/aws_cloud_search.rb', line 22

def self.search_url(domain, region="us-east-1")
  "http://search-#{domain}.#{region}.cloudsearch.amazonaws.com"
end