Skip to content

Commit ebea93a

Browse files
MattCollins84glynnbird
authored andcommitted
Discovery (#49)
* Start of adding CMS page * CMS delete works * CMS first attempt feature complete * First attempt at API Reference * tidy up API ref * cache parameter * Data based examples on input forms, Inline deletes, Clickable Facets, Some tidy up * Cleaner local configuration * Readme tidy up * Update README.md * Use Passport to allow basic HTTP auth in lockdown mode * Endpoints for autocompletes * Use SAS with hardcoded config * Start to implement service discovery/registration * A few tweaks * Websockets and UI auto-updating for discovery - env not quite working yet * All working, with a few caveats * Tidy up of discovery branch * Tidy up of SOS, remove un-needed debug * Etcd with unstrict SSL * Add Simple Metrics Microservice as discoverable service * Update Readme to include Discovery Mode and remove cache * Enable caching and autocompletes when those services are password protected * Changes made to reflect renaming * Change metrics to Logging
1 parent 181540c commit ebea93a

25 files changed

+1274
-328
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ start.sh
88
.project
99
npm-debug.log
1010
.vscode
11-
todo.txt
11+
todo.txt
12+
cert.ca

README.md

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@ The application uses these Bluemix services:
1212
* a Cloudant database
1313
* a Redis in-memory database from Compose.io (Optional)
1414

15-
Once the data is uploaded, you can use the UI to browse and manage your data via the integrated CMS. Additionally, a CORS-enabled, cached API endpoint is available at `<your domain name>/search`. The endpoint takes advantage of Cloudant's built-in integration for Lucene full-text indexing. Here's what you get:
15+
Once the data is uploaded, you can use the UI to browse and manage your data via the integrated CMS. Additionally, a CORS-enabled API endpoint is available at `<your domain name>/search`. The endpoint takes advantage of Cloudant's built-in integration for Lucene full-text indexing. Here's what you get:
1616

1717
* fielded search - `?q=colour:black+AND+brand:fender`
1818
* free-text search - `?q=black+fender+strat`
1919
* pagination - `?q=black+fender+strat&bookmark=<xxx>`
2020
* faceting
21-
* caching of popular searches
2221

2322
You can use this along with the rest of the API to integrate the Simple Search Service into your apps. For a full API reference, [click here](https://github.com/ibm-cds-labs/simple-search-service#api-reference).
2423

25-
While this app is a demo to showcase how easily you can build an app on Bluemix using Node.js and Cloudant, it also provides a mature search API that scales with the addition of multiple Simple Search Service nodes and a centralized cache using Redis by Compose.io. In fact, a similar architecture powers the search experience in the Bluemix services catalog.
24+
While this app is a demo to showcase how easily you can build an app on Bluemix using Node.js and Cloudant, it also provides a mature search API that scales with the addition of multiple Simple Search Service nodes. In fact, a similar architecture powers the search experience in the Bluemix services catalog.
2625

2726
A more detailed walkthrough of using Simple Search Service is available [here](https://developer.ibm.com/clouddataservices/2016/01/21/introducing-simple-faceted-search-service/).
2827

@@ -44,25 +43,43 @@ The fastest way to deploy this application to Bluemix is to click the **Deploy t
4443

4544
Clone this repository then run `npm install` to add the Node.js libraries required to run the app.
4645

47-
Then create some environment variables that contain your Cloudant URL, and optionally, your Redis details:
46+
Then create some environment variables that contain your Cloudant URL.
4847

4948
```sh
5049
# Cloudant URL
5150
export SSS_CLOUDANT_URL='https://<USERNAME>:<PASSWORD>@<HOSTNAME>'
52-
53-
# Redis Host and password
54-
export SSS_REDIS_HOST='127.0.0.1:6379'
55-
export SSS_REDIS_PASSWORD='redispassword'
5651
```
5752

58-
replacing the `USERNAME`, `PASSWORD` and `HOSTNAME` placeholders for your own Cloudant account's details. If your Redis server does not require a password, do not set the `SSS_REDIS_PASSWORD` environment variable.
53+
replacing the `USERNAME`, `PASSWORD` and `HOSTNAME` placeholders for your own Cloudant account's details.
5954

6055
Then run:
6156

6257
```sh
6358
node app.js
6459
```
6560

61+
## Service Registry
62+
63+
The Simple Search Service utilises [Etcd](https://github.com/coreos/etcd) to discover and utilise some of our other Simple Services to extend and improve the service.
64+
65+
Other services that are available to the Simple Search Service are:
66+
67+
* [The Simple Autocomplete Service](https://github.com/ibm-cds-labs/simple-autocomplete-service) - Add auto completion to the CMS
68+
* [The Simple Caching Service](https://github.com/MattCollins84/simple-cache-service) - Enable caching of popular searches
69+
* [Metrics Collector Microservice](https://github.com/ibm-cds-labs/metrics-collector-microservice) - Enable logging of searches
70+
71+
### Enabling the Service Registry
72+
73+
Enabling the Service Registry requires setting an environment variable, `ETCD_URL`. This should be the URL of your Etcd instance including any basic HTTP authentication information
74+
75+
```
76+
export ETCD_URL='http://username:password@etcd.exmple.com'
77+
```
78+
79+
If the Service Registry is enabled, any discovered services will be displayed on the Services page, with a toggle to enable or disable these services.
80+
81+
Once enabled these services will automatically be integrated into the Simple Search Service.
82+
6683
## Lockdown mode
6784

6885
If you have uploaded your content into the Simple Search Service but now want only the `/search` endpoint to be available publicly, you can enable "Lockdown mode".
@@ -80,6 +97,7 @@ When lockdown mode is detected, all web requests will be get a `401 Unauthorised
8097

8198
If you wish to get access to the Simple Search Service whilst in lockdown mode, you can enable basic HTTP authentication by setting two more environment variables:
8299

100+
83101
* `SSS_LOCKDOWN_USERNAME`
84102
* `SSS_LOCKDOWN_PASSWORD`
85103

@@ -129,13 +147,6 @@ It is possible to alter the amount of results returned using the `limit` paramet
129147
GET /search?q=black&bookmark=<...>&limit=10
130148
```
131149

132-
It is possible to alter whether or not to use the cache via the `cache` parameter (defaults to true).
133-
134-
```bash
135-
# Return the next set of docs where 'black' is mentioned, don't use the cache
136-
GET /search?q=black&bookmark=<...>&cache=false
137-
```
138-
139150
#### Example Response
140151

141152
All searches will respond in the same way.
@@ -170,7 +181,6 @@ All searches will respond in the same way.
170181
"Black": 19
171182
}
172183
},
173-
"from_cache": true, // did this response come from the cache?
174184
"_ts": 1467108849821
175185
}
176186
```

0 commit comments

Comments
 (0)