Giter VIP home page Giter VIP logo

compose-elasticsearch-helloworld-nodejs's Introduction

compose-elasticsearch-helloworld-nodejs overview

compose-elasticsearch-helloworld-nodejs is a sample Bluemix application which shows you how to connect to an IBM Compose for Elasticsearch for Bluemix service using Node.js.

Running the app on Bluemix

  1. If you do not already have a Bluemix account, sign up here

  2. Download and install the Cloud Foundry CLI tool

  3. Clone the app to your local environment from your terminal using the following command:

git clone https://github.com/IBM-Bluemix/compose-elasticsearch-helloworld-nodejs.git
  1. cd into this newly created directory

  2. Open the manifest.yml file and change the host value to something unique. The host you choose will determinate the subdomain of your application's URL: <host>.mybluemix.net

  3. Connect to Bluemix in the command line tool and follow the prompts to log in.

$ cf api https://api.ng.bluemix.net
$ cf login
  1. If you don't already have a Compose for Elasticsearch service in Bluemix, create one.

Note : The Compose for Elasticsearch service does not offer a free plan. For details of pricing, see the Pricing Plans section of the Compose for Elasticsearch service in Bluemix.

$ cf create-service compose-for-elasticsearch Standard my-compose-for-elasticsearch-service
  1. Bind the service to the application.
$ cf bind-service compose-elasticsearch-helloworld-nodejs my-compose-for-elasticsearch-service
  1. Push the app to Bluemix.
$ cf push

Your application is now running at <host>.mybluemix.net.

The node-elasticsearch-helloworld app displays the contents of an examples Elasticsearch index. To demonstrate that the app is connected to your service, add some words to the index. The words are displayed as you add them, with the most recently added words displayed first.

Code Structure

File Description
server.js Establishes a connection to the Elasticsearch index using credentials from VCAP_ENV and handles create and read operations on the index.
main.js Handles user input for a PUT command and parses the results of a GET command to output the contents of the Elasticsearch index.

The app uses a PUT and a GET operation:

  • PUT

    • takes user input from main.js
    • uses the client.index method to add user input to the index
  • GET

    • uses the client.search method to retrieve the contents of the words type
    • returns the response to main.js

Privacy Notice

The sample web application includes code to track deployments to Bluemix and other Cloud Foundry platforms. The following information is sent to a Deployment Tracker service on each deployment:

  • Application Name (application_name)
  • Space ID (space_id)
  • Application Version (application_version)
  • Application URIs (application_uris)

This data is collected from the VCAP_APPLICATION environment variable in IBM Bluemix and other Cloud Foundry platforms. This data is used by IBM to track metrics around deployments of sample applications to IBM Bluemix. Only deployments of sample applications that include code to ping the Deployment Tracker service will be tracked.

Disabling Deployment Tracking

Deployment tracking can be disabled by removing require("cf-deployment-tracker-client").track(); from the beginning of the server.js file.

compose-elasticsearch-helloworld-nodejs's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.