Skip to content
This repository was archived by the owner on Feb 6, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions lib/aws_cloud_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,25 @@ module AWSCloudSearch
# for future reference in case AWS-CS updates to XML 1.1 char compliance
#INVALID_CHAR_XML11 = /[^\u0001-\uD7FF\uE000-\uFFFD]/m

DEFAULT_OPTIONS = {
region: 'us-east-1',
endpoint_base_domain: 'cloudsearch.amazonaws.com',
configuration_url: 'https://cloudsearch.us-east-1.amazonaws.com'
}.freeze

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

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

def self.configuration_url
"https://cloudsearch.us-east-1.amazonaws.com"
def self.configuration_url(options={})
options = DEFAULT_OPTIONS.merge(options)
options[:configuration_url]
end

# Initialize the module
Expand Down
7 changes: 3 additions & 4 deletions lib/aws_cloud_search/cloud_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

module AWSCloudSearch
class CloudSearch

def initialize(domain, region="us-east-1")
@doc_conn = AWSCloudSearch::create_connection( AWSCloudSearch::document_url(domain, region) )
@search_conn = AWSCloudSearch::create_connection( AWSCloudSearch::search_url(domain, region) )
def initialize(domain, options={})
@doc_conn = AWSCloudSearch::create_connection( AWSCloudSearch::document_url(domain, options) )
@search_conn = AWSCloudSearch::create_connection( AWSCloudSearch::search_url(domain, options) )
end

# Sends a batch of document updates and deletes by invoking the CloudSearch documents/batch API
Expand Down