1
1
# AddSearch Search API Client for JavaScript
2
2
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.
6
6
7
7
## 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 )
9
9
``` html
10
10
<
script src =
" https://cdn.jsdelivr.net/npm/[email protected] /dist/addsearch-js-client.min.js" ></
script >
11
11
```
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:
13
13
``` sh
14
14
npm install addsearch-js-client --save
15
15
```
@@ -209,10 +209,11 @@ Use the following function to get more or less facets.
209
209
client .setNumberOfFacets (20 );
210
210
```
211
211
212
- #### Numeric range facets
212
+ #### Numerical range facets
213
213
Group numerical custom fields into range buckets.
214
214
``` 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
216
217
var ranges = [
217
218
{' to' : 100 },
218
219
{' from' : 100 , ' to' : 200 },
@@ -223,6 +224,15 @@ var ranges = [
223
224
client .addRangeFacet (' custom_fields.price' , ranges);
224
225
```
225
226
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
+
226
236
### Search analytics
227
237
#### Send search event to analytics
228
238
When search is executed, send the event to your AddSearch Analytics Dashboard.
0 commit comments