serverless-autocomplete v1.2.0
serverless-autocomplete
This npm package is a command-line utility to help create autocomplete microservices from text files. It creates the microservice with your data embedded and returns you the URL of the service which you can use in your web forms.
Node.js is required to install the acsetup utility and an IBM OpenWhisk account to create the serverless microservices.
Installation
Ensure you have Node.js and npm installed. Then run:
npm install -g serverless-autocomplete(sudo may also be required before this command in some cases).
Make sure you have downloaded the OpenWhisk command-line utility ibmcloud fn and have authenticated it with your IBM Cloud credentials.
Creating autocomplete services
You can now create as many autocomplete microservices as you need. Take text file containing the strings you wish to be used. The files should contain one string per line e.g.
George Washington
John Adams
Thomas Jefferson
James Madison
James MonroeTo create an autocomplete index, simple run acsetup with the path to the text file of strings:
> acsetup uspresidents.txtIt will return you:
- the URL of your autocomplete service
 - an example 
curlstatement - an HTML snippet that shows your service embedded into a web page
 
If you don't have data to hand then we've got you covered.
acsetup countries.txt
acsetup names.txt
acsetup uktowns.txtWorking with the API
Your service URL will look something like this:
https://openwhisk.ng.bluemix.net/api/v1/web/USER/autocomplete/INDEXwhere USER is your Bluemix username + space  e.g. sue@gmail.com_dev and INDEX is the name of your index e.g. uspresidents.
To perform an autocomplete operation, the API call requires a term parameter containing the string to be completed:
https://openwhisk.ng.bluemix.net/api/v1/web/USER/autocomplete/INDEX?term=GeIt outputs a JSON array e.g.
["George H. W. Bush","George W. Bush","George Washington","Gerald Ford"]If no matches are found, an empty array is returned:
[]The API is compatible with the jQuery Autocomplete API but can be plumbed into any front-end code.