pkhanal / discovery-nodejs

This is the Watson Discovery Service Demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Discovery Demo

Demo: https://discovery-reviews-demo.mybluemix.net/

Getting started

  1. You need a Bluemix account. If you don't have one, sign up.

  2. Connect to Bluemix with the command line tool.

cf api https://api.ng.bluemix.net
cf login
  1. Create and retrieve service keys to access the Discovery service:
cf create-service discovery standard my-discovery-service
cf create-service-key my-discovery-service myKey
cf service-key my-discovery-service myKey
  1. Use the credentials that are returned in step 5 to retrieve the IBM curated News environment_id from the list of environments:
curl -X GET -u <username>:<password> https://gateway.watsonplatform.net/discovery/api/v1/environments?version=2016-11-07

Output:

{
  "environments": [{
    "created": "2016-11-30T15:41:22.298Z",
    "description": "Watson News cluster environment",
    "environment_id": "bb6ffe96-53d5-44b3-8838-922d4665df8d",
    "index_capacity": {
      ...
    },
    "memory_usage": {
      ...
    },
    "name": "Watson News Environment",
    "read_only": true,
    "status": "active",
    "updated": "2016-11-30T15:41:22.298Z"
  }]
}
  1. Use the environment_id from step 6 to retrieve the IBM curated News collection_id from the list of collections:
curl -X GET -u <username>:<password> https://gateway.watsonplatform.net/discovery/api/v1/environments/bb6ffe96-53d5-44b3-8838-922d4665df8d/collections?version=2016-11-07

Output:

{
  "collections": [
    {
      "collection_id": "0288e2a0-a1c1-4a38-a376-3c3bd89e927b",
      "description": "Watson News T3 collection",
      "name": "v5-fullnews-t3-2016",
      "configuration_id": "f916ddcd-961e-4668-b46b-2b0f9fe8f002",
      "language": "en_us",
      "status": "active",
      "created": "2016-11-30T15:41:22.318Z",
      "updated": "2016-11-30T15:41:22.318Z"
    }
  ]
}
  1. Create an .env file in the root directory by copying the sample .env.example file using the following command:
cp .env.example .env

Update the .env with your service instace information, your environment_id, and your collection_id that you retrieved in steps 5 to 7.

The .env file will look something like the following:

DISCOVERY_USERNAME=<username>
DISCOVERY_PASSWORD=<password>

DISCOVERY_ENVIRONMENT=<environment>
DISCOVERY_COLLECTION=<collection>
  1. Install the needed application dependencies with this command:
npm install
  1. Start the application locally:
npm start
  1. Point your browser to http://localhost:3000.

  2. When you're ready, push the application to Bluemix with this command:

cf push

After completing these steps, you are ready to test your application. Start a browser and enter the URL of your application.

        <your application name>.mybluemix.net

For more details about developing applications that use Watson Developer Cloud services in Bluemix, see Getting started with Watson Developer Cloud and Bluemix.

Troubleshooting

  • The main source of troubleshooting and recovery information is the Bluemix log. To view the log, run this command:

    cf logs <application-name> --recent
  • For more details about the service, see the documentation for the Discovery service.


Directory structure

.
├── app.js                      // express routes
├── config                      // express configuration
│   ├── error-handler.js
│   ├── express.js
│   └── security.js
├── manifest.yml
├── package.json
├── public                      // static resources
├── server.js                   // entry point
├── test                        // tests
└── views                       // react components

License

This sample code is licensed under Apache 2.0.

Contributing

See CONTRIBUTING.

Open Source @ IBM

Find more open source projects on the IBM Github Page

Privacy Notice

Sample web applications that include this package may be configured to track deployments to IBM Bluemix and other Cloud Foundry platforms. The following information is sent to a Deployment Tracker service on each deployment:

  • Node.js package version
  • Node.js repository URL
  • Application Name (application_name)
  • Space ID (space_id)
  • Application Version (application_version)
  • Application URIs (application_uris)
  • Labels of bound services
  • Number of instances for each bound service and associated plan information

This data is collected from the package.json file in the sample application and the VCAP_APPLICATION and VCAP_SERVICES environment variables 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 to measure the usefulness of our examples, so that we can continuously improve the content we offer to you. Only deployments of sample applications that include code to ping the Deployment Tracker service will be tracked.

About

This is the Watson Discovery Service Demo


Languages

Language:JavaScript 55.8%Language:CSS 42.2%Language:Python 2.1%