NOTICE: This gem is no longer maintained.
It is now provided as reference for those operating with a CloudSearch 2011 backed search system.
We recommend updating to the current (2013) API and the official aws/aws-sdk-ruby gems
This gem is an implementation of the Amazon Web Service CloudSearch 2011 API.
The AWS CloudSearch service is comprised of three API end-points:
This gem currently supports only the search and document batching APIs. To access the CloudSearch configuration API from Ruby, use the aws-sdk gem.
Spoke developed this library in a short period of time in order to migrate from IndexTank to AWS CloudSearch. As such, there are a few features that are missing that we would like to build over time.
Add this line to your application's Gemfile:
gem 'aws_cloud_search'
And then execute:
$ bundle
Or install it yourself as:
$ gem install aws_cloud_search
Note: work in progress
# if your CloudSearch domain is in the us-east-1 region and availability zone
ds = AWSCloudSearch::CloudSearch.new('your-domain-name-53905x4594jxty')
# if your CloudSearch domain is in a different AWS region and/or availability zone
ds = AWSCloudSearch::CloudSearch.new('your-domain-53905x4594jxty', 'us-west-2')
Better yet, store those values in a YAML configuration file or in environment variables.
Since AWS charges per batch, it is best to batch as many documents as you can in each batch. Document#new
takes an optional parameter auto_version
which you set to true to automatically set the version, the default value is false.
doc1 = AWSCloudSearch::Document.new(true)
doc1.id = '12345677890abcdef'
doc1.lang = 'en'
doc1.add_field('name', 'Jane Williams')
doc1.add_field('type', 'person')
doc2 = AWSCloudSearch::Document.new(true)
doc2.id = '588687626634767634'
doc2.lang = 'en'
doc2.add_field :name, 'Bob Dobalina'
doc2.add_field :type, 'person'
batch = AWSCloudSearch::DocumentBatch.new
batch.add_document doc1
batch.add_document doc2
doc3 = AWSCloudSearch::Document.new(true)
doc3.id = 'fedcba0987654321'
batch.delete_document doc3
ds.documents_batch(batch)
See the related CloudSearch documentation
search_request = AWSCloudSearch::SearchRequest.new
search_request.q = "Bob"
search_results = ds.search(search_request)
search_results.hits.each do |hit|
puts hit['id']
puts hit['name']
end
See the related CloudSearch documentation
search_request = AWSCloudSearch::SearchRequest.new
search_request.bq = "type:'person'"
search_results = ds.search(search_request)
search_results.hits.each do |hit|
puts hit['id']
puts hit['name']
end
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)0.0.2 Added support for faceting