1 | [![Build Status](https://travis-ci.org/ucsf-ckm/amalgamatic.svg?branch=master)](https://travis-ci.org/ucsf-ckm/amalgamatic)
|
2 |
|
3 | amalgamatic
|
4 | ===========
|
5 |
|
6 | Amalgamatic is a pluggable metasearch tool. It let's you choose a series of
|
7 | sources to search and then search them.
|
8 |
|
9 | Search all the things!
|
10 |
|
11 | ## Quickstart
|
12 |
|
13 | ````
|
14 | // Load amalgamatic
|
15 | var amalgamatic = require('amalgamatic');
|
16 |
|
17 | // Load some plugins to search SFX and PubMed.
|
18 | var sfx = require('amalgamatic-sfx');
|
19 | var pubmed = require('amalgamatic-pubmed');
|
20 |
|
21 | // Add the plugins to amalgamatic.
|
22 | amalgamatic.add('sfx', sfx);
|
23 | amalgamatic.add('pubmed', pubmed);
|
24 |
|
25 | // Do a search!
|
26 | amalgamatic.search({searchTerm: 'medicine'}, function (results) {
|
27 | console.dir(results);
|
28 | });
|
29 | ````
|
30 |
|
31 | ## API
|
32 |
|
33 | ### amalgamatic.add(name, plugin)
|
34 |
|
35 | Add (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 |
|
41 | Execute 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 |