AddSearch Search API Client for JavaScript
AddSearch is a hosted search platform for all your web content. This API
Client lets you easily use the AddSearch Search API
from your JavaScript code on web browsers or with Node.js.
Quick Start
The library is available on the global CDN jsDelivr:
<script src="https://cdn.jsdelivr.net/npm/addsearch-js-client@0.1/dist/addsearch-js-client.min.js"></script>
To install the library locally or to use it with Node.js:
npm install addsearch-js-client --save
Execute the first search query
var client = new AddSearchClient('YOUR PUBLIC SITEKEY');
var cb = function(res) {
console.log(res);
}
client.search('keyword', cb);
Publicly accessible functions
The client provides the following functions.
Fetch search results
client.search('keyword', callback);
client.search(callback);
Fetch search suggestions
client.suggestions('a', callback);
Use fuzzy matching
client.useFuzzyMatch(false);
Define language filter
client.setLanguage('en');
Define publishing date filters
client.setDateFilter('2019-01-01', '2019-01-31');
Define category filters
Filter by URL patterns, document types or addsearch-category meta tag values.
See the full documentation.
client.setCategoryFilters('doctype_pdf,products');
Custom field filters
Filter by custom fields. Custon fields can be defined in meta tags or AddSearch crawler can pick them up from your HTML or JSON data.
See the full documentation.
client.addCustomFieldFilter('city','berlin');
client.addCustomFieldFilter('city','paris');
client.addCustomFieldFilter('city','boston');
client.removeCustomFieldFilter('city','paris');
client.removeCustomFieldFilter('city');
Manage paging
client.setPaging(page, pageSize, sortBy, sortOrder);
client.nextPage();
client.previousPage();
Supported web browsers and node.js versions
The client is tested on
- Chrome
- Firefox
- Edge
- Safari 6.1+
- Internet Explorer 10+
- Node.js 4+
Development
To modify this client library, clone this repository to your computer and execute following commands.
Install dependencies
npm install
Run tests
npm test
Build
npm run build
Built bundle is saved under the dist/ folder
Support
Feel free to send any questions, ideas and suggestions at support@addsearch.com.