UNPKG

1.98 kBMarkdownView Raw
1[![Build Status](https://travis-ci.org/ucsf-ckm/amalgamatic.svg?branch=master)](https://travis-ci.org/ucsf-ckm/amalgamatic)
2
3amalgamatic
4===========
5
6Amalgamatic is a pluggable metasearch tool. It let's you choose a series of
7sources to search and then search them.
8
9Search all the things!
10
11## Quickstart
12
13````
14// Load amalgamatic
15var amalgamatic = require('amalgamatic');
16
17// Load some plugins to search SFX and PubMed.
18var sfx = require('amalgamatic-sfx');
19var pubmed = require('amalgamatic-pubmed');
20
21// Add the plugins to amalgamatic.
22amalgamatic.add('sfx', sfx);
23amalgamatic.add('pubmed', pubmed);
24
25// Do a search!
26amalgamatic.search({searchTerm: 'medicine'}, function (results) {
27 console.dir(results);
28});
29````
30
31## API
32
33### amalgamatic.add(name, plugin)
34
35Add (register) a plugin for a collection.
36* `name`: A string that will be used to identify the collection.
37* `plugin`: A plugin object.
38
39### amalgamatic.search(query, callback)
40
41Execute a search query.
42* `query`: An object optionally containing the following properties
43 * `searchTerm`: String containing the search term(s). Default is empty string which returns no results.
44 * `collections`: Array of strings representing the plugins you wish to search. Default is to use all registered plugins.
45 * `maxResults`: Integer representing the maximum number of results to return from each plugin. Use 0 or a negative number (or omit the property altogether) to return the default number of results from each plugin.
46 * `pluginCallback`: A function to execute after each plugin returns a result. It is called with two parameters.
47 * `error`: An Error object or `null` if no error occurred.
48 * `results`: An object containing the results from the plugin.
49* `callback`: A function to execute after all plugins have returned results. It is called with two parameters.
50 * `error`: An Error object or `null` if no error occurred.
51 * `results`: An object containing all the results from all the plugins.
\No newline at end of file