Skip to content

Commit ad5ada6

Browse files
authored
Fixes and updates to the documentation. (#107)
* Readme: Format code in headline as code * Readme: Document the fields of config.aggregations * Readme: Fix sort value in example In the readme, the `name_asc` in `.search` corresponds to the `configuration.sortings.name_asc` but in this example the key is different. * Readme: Remove search example with `prefilter` I cannot find `prefilter` in the code https://github.com/itemsapi/itemsjs/search?q=prefilter nor readme. * Readme: Remove `isExactSearch` from configuration This is an option for the search, not the configuration based on the readme https://github.com/itemsapi/itemsjs/blob/master/README.md#itemsjssearchoptions and code.
1 parent 1f1ea7a commit ad5ada6

2 files changed

Lines changed: 16 additions & 19 deletions

File tree

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Examples:
166166

167167
## API
168168

169-
### var itemsjs = ItemsJS(data, [configuration])
169+
### `var itemsjs = ItemsJS(data, [configuration])`
170170

171171
#### `data`
172172

@@ -178,13 +178,22 @@ Responsible for defining global configuration. Look for full example here - [con
178178

179179
- **`aggregations`** filters configuration i.e. for `tags`, `actors`, `colors`, etc. Responsible for generating facets.
180180

181+
Each filter can have it's own configuration. You can access those as `buckets` on the `search()` response.
182+
183+
- **`title`** Human readable filter name
184+
- **`size`** Number of values provided for this filter (Default: `10`)
185+
- **`sort`** Values sorted by `count` (Default) or `term` for the value name
186+
- **`order`** `asc` | `desc`
187+
- **`show_facet_stats`** `true` | `false` (Default) to retrieve the min, max, avg, sum rating values from the whole filtered dataset
188+
- **`conjunction`** `true` (Default) stands for an _AND_ query (results have to fit all selected facet-values), `false` for an _OR_ query (results have to fit one of the selected facet-values)
189+
181190
- **`sortings`** you can configure different sortings like `tags_asc`, `tags_desc` with options and later use it with one key.
182191

183192
- **`searchableFields`** an array of searchable fields.
184193

185194
- **`native_search_enabled`** if native full text search is enabled (true | false. It's enabled by default)
186195

187-
### itemsjs.search(options)
196+
### `itemsjs.search(options)`
188197

189198
#### `options`
190199

@@ -206,7 +215,7 @@ Responsible for defining global configuration. Look for full example here - [con
206215

207216
- **`is_all_filtered_items`** set to `true` if you want to return the whole filtered dataset.
208217

209-
### itemsjs.aggregation(options)
218+
### `itemsjs.aggregation(options)`
210219

211220
It returns full list of filters for specific aggregation
212221

@@ -216,9 +225,9 @@ It returns full list of filters for specific aggregation
216225
- **`per_page`** filters per page
217226
- **`page`** page number
218227
- **`query`** used for quering filters. It's not full text search
219-
- **`conjunction`** choose between AND, OR
228+
- **`conjunction`** `true` (Default) stands for an _AND_ query, `false` for an _OR_ query
220229

221-
### itemsjs.similar(id, options)
230+
### `itemsjs.similar(id, options)`
222231

223232
It returns similar items to item for given id
224233

@@ -230,7 +239,7 @@ It returns similar items to item for given id
230239
- **`page`** page number
231240

232241

233-
### itemsjs.reindex(data)
242+
### `itemsjs.reindex(data)`
234243

235244
It's used in case you need to reindex the whole data
236245

docs/configuration.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ var itemsjs = require('itemsjs')(data, {
3838
}
3939
},
4040
searchableFields: ['name', 'tags'],
41-
isExactSearch: true // Default false
4241
});
4342
```
4443

@@ -48,7 +47,7 @@ var itemsjs = require('itemsjs')(data, {
4847
// aggregation
4948
var movies = itemsjs.search({
5049
per_page: 1,
51-
sort: 'name_asc',
50+
sort: 'year_asc', // key from itemsjs configuration `sortings` object
5251
filters: {
5352
tags: ['1980s']
5453
}
@@ -78,14 +77,3 @@ var result = itemsjs.search({
7877
}
7978
});
8079
```
81-
82-
```js
83-
var result = itemsjs.search({
84-
query: 'shoes',
85-
prefilter: function(items) {
86-
return items.filter(item => {
87-
return item.price > 100;
88-
});
89-
}
90-
});
91-
```

0 commit comments

Comments
 (0)