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
```
@@ -212,7 +212,8 @@ client.setNumberOfFacets(20);
212
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 },
@@ -224,10 +225,11 @@ client.addRangeFacet('custom_fields.price', ranges);
224
225
```
225
226
226
227
### Field statistics
227
- Get the minimum, maximum, and average values of a numerical or date-based custom field. The information
228
+ Get minimum, maximum, and average values of a numerical or date-based custom field. The information
228
229
is handy for applications like range filtering.
229
230
``` js
230
- // Search response will have fieldStats element with information like {min: 1230, max: 1590, avg: 1382}
231
+ // Search response will have a fieldStats element with information like
232
+ // custom_fields.price: {min: 1230, max: 1590, avg: 1382}
231
233
client .addStatsField (' custom_fields.price' );
232
234
```
233
235
0 commit comments