Skip to content

Commit

Permalink
Fixes and updates to the documentation. (#107)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
tordans authored Apr 7, 2022
1 parent 1f1ea7a commit ad5ada6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Examples:

## API

### var itemsjs = ItemsJS(data, [configuration])
### `var itemsjs = ItemsJS(data, [configuration])`

#### `data`

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

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

Each filter can have it's own configuration. You can access those as `buckets` on the `search()` response.

- **`title`** Human readable filter name
- **`size`** Number of values provided for this filter (Default: `10`)
- **`sort`** Values sorted by `count` (Default) or `term` for the value name
- **`order`** `asc` | `desc`
- **`show_facet_stats`** `true` | `false` (Default) to retrieve the min, max, avg, sum rating values from the whole filtered dataset
- **`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)

- **`sortings`** you can configure different sortings like `tags_asc`, `tags_desc` with options and later use it with one key.

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

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

### itemsjs.search(options)
### `itemsjs.search(options)`

#### `options`

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

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

### itemsjs.aggregation(options)
### `itemsjs.aggregation(options)`

It returns full list of filters for specific aggregation

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

### itemsjs.similar(id, options)
### `itemsjs.similar(id, options)`

It returns similar items to item for given id

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


### itemsjs.reindex(data)
### `itemsjs.reindex(data)`

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

Expand Down
14 changes: 1 addition & 13 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ var itemsjs = require('itemsjs')(data, {
}
},
searchableFields: ['name', 'tags'],
isExactSearch: true // Default false
});
```

Expand All @@ -48,7 +47,7 @@ var itemsjs = require('itemsjs')(data, {
// aggregation
var movies = itemsjs.search({
per_page: 1,
sort: 'name_asc',
sort: 'year_asc', // key from itemsjs configuration `sortings` object
filters: {
tags: ['1980s']
}
Expand Down Expand Up @@ -78,14 +77,3 @@ var result = itemsjs.search({
}
});
```

```js
var result = itemsjs.search({
query: 'shoes',
prefilter: function(items) {
return items.filter(item => {
return item.price > 100;
});
}
});
```

0 comments on commit ad5ada6

Please sign in to comment.