11# AddSearch Search API Client for JavaScript
22
3- [ AddSearch] ( https://www.addsearch.com ) is a hosted search platform for all your web content . This API
4- Client lets you easily use the [ AddSearch Search API] ( https://www.addsearch.com/support /api-reference / )
5- from your JavaScript code on web browsers or with Node.js.
3+ [ AddSearch] ( https://www.addsearch.com ) is a Search-as-a-Service for all your search needs . This API
4+ Client lets you easily use the [ AddSearch Search API] ( https://www.addsearch.com/docs /api/ )
5+ with JavaScript on web browsers or from Node.js.
66
77## Quick Start
8- The library is available on the global CDN [ jsDelivr:] ( https://www.jsdelivr.com/ )
8+ The library is available on the global CDN [ jsDelivr:] ( https://www.jsdelivr.com/package/npm/addsearch-js-client )
99``` html
1010<
script src =
" https://cdn.jsdelivr.net/npm/[email protected] /dist/addsearch-js-client.min.js" ></
script >
1111```
12- To install the library locally or to use it with Node.js:
12+ Or install the library locally to use it with Node.js:
1313``` sh
1414npm install addsearch-js-client --save
1515```
@@ -209,10 +209,11 @@ Use the following function to get more or less facets.
209209client .setNumberOfFacets (20 );
210210```
211211
212- #### Numeric range facets
212+ #### Numerical range facets
213213Group numerical custom fields into range buckets.
214214``` js
215- // Define ranges. E.g. products with price $0-$100, $100-$200, and over $200 (from value is inclusive, to value is exclusive)
215+ // Define ranges. E.g. products with price $0-$100, $100-$200, and over $200.
216+ // From value is inclusive, to value is exclusive
216217var ranges = [
217218 {' to' : 100 },
218219 {' from' : 100 , ' to' : 200 },
@@ -223,6 +224,15 @@ var ranges = [
223224client .addRangeFacet (' custom_fields.price' , ranges);
224225```
225226
227+ ### Field statistics
228+ Get minimum, maximum, and average values of a numerical or date-based custom field. The information
229+ is handy for applications like range filtering.
230+ ``` js
231+ // Search response will have a fieldStats element with information like
232+ // custom_fields.price: {min: 1230, max: 1590, avg: 1382}
233+ client .addStatsField (' custom_fields.price' );
234+ ```
235+
226236### Search analytics
227237#### Send search event to analytics
228238When search is executed, send the event to your AddSearch Analytics Dashboard.
0 commit comments