cloudfoundry-samples/rails-elastic-search

Name: rails-elastic-search

Owner: Cloud Foundry Sample Applications

Description: A Rails app that uses Tire to interact with Elastic Search deployed on Cloud Foundry

Created: 2012-05-07 23:56:14.0

Updated: 2013-11-01 10:20:44.0

Pushed: 2012-06-04 21:25:25.0

Homepage:

Size: 120

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

rails-elastic-search

Rails app that uses Tire to interact with Elastic Search deployed on Cloud Foundry. This app was originally created by running the “rails new searchapp” command explained under “ActiveModel Integration” in the Tire README.

Setting up Elastic Search

This app connects to an instance of Elastic Search running on Cloud Foundry. Follow these instructions to deploy Elastic Search as a standalone application:

asticSearch, by default, binds itself to the 0.0.0.0 address, and listens
 port [9200-9300] for HTTP traffic and on port [9300-9400] for node-to-node
mmunication. (the range means that if the port is busy, it will automatically
y the next port).

t the bind address specifically (IPv4 or IPv6):

ork.bind_host: ${VCAP_APP_HOST}

t the address other nodes will use to communicate with this node. If not
t, it is automatically derived. It must point to an actual IP address.

twork.publish_host: 192.168.0.1

t both 'bind_host' and 'publish_host':

ork.host: ${VCAP_APP_HOST}

t a custom port for the node to node communication (9300 by default):

ansport.tcp.port: 9300

able compression for all communication between nodes (disabled by default):

ansport.tcp.compress: true

t a custom port to listen for HTTP traffic:

.port: ${VCAP_APP_PORT}
lasticsearch-0.19.2
ails-elastic-search/elastic-search-manifest.yml .
push --manifest=elastic-search-manifest.yml

You should now be able to direct REST requests to myelasticsearch.cloudfoundry.com

Deploying rails-elastic-search to Cloud Foundry

Cloud Foundry runs your Rails app in production mode, therefore you need to precompile assets prior to deploying:

 assets:precompile

You also need to update the Tire configuration to point to the URL you've assigned to Elastic Search. Edit the following line in config/environments/production.rb:

::Configuration.url "http://myelasticsearch.cloudfoundry.com"

To deploy the application to Cloud Foundry, simply use the provided manifest.yml file. You need only to provide the application with a name and URL.

push
d you like to deploy from the current directory? [Yn]:
ication Name: searchapp
ication Deployed URL [searchapp.cloudfoundry.com]:
Seeding the database

Use the vmc rails-console to seed the database once your application is deployed to Cloud Foundry. This will add some example articles to the app's database as well as elasticsearch (through the use of Tire). Note that memory used while running the console contributes to your overall application memory limit.

rails-console searchapp
oying tunnel application 'caldecott'.
ading Application:
ecking for available resources: OK
cking application: OK
loading (1K): OK
 Status: OK
ing Application 'caldecott': OK
ting Application 'caldecott': OK
ecting to 'searchapp' console: OK

):001:0> `rake db:seed`

):002:0> exit

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.