You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -230,6 +230,34 @@ Responsible for defining global configuration. Look for full example here - [con
230
230
231
231
-**`ids`** array of item identifiers to limit the results to. Useful when combining with external full-text search engines (e.g. MiniSearch).
232
232
233
+
#### Optional runtime facets (DX helper)
234
+
235
+
Instead of static `filters` you can pass `facets` with selections and runtime options (per-facet AND/OR, bucket size/sort):
236
+
237
+
```js
238
+
constresult=itemsjs.search({
239
+
query:'drama',
240
+
facets: {
241
+
tags: {
242
+
selected: ['1980s', 'historical'],
243
+
options: {
244
+
conjunction:'OR', // AND/OR for this facet only
245
+
size:30, // how many buckets to return
246
+
sortBy:'count', // 'count' | 'key'
247
+
sortDir:'desc', // 'asc' | 'desc'
248
+
hideZero:true, // hide buckets with doc_count = 0
249
+
chosenOnTop:true, // selected buckets first
250
+
},
251
+
},
252
+
},
253
+
});
254
+
// response contains data.aggregations and an alias data.facets
255
+
```
256
+
257
+
`facets` is an alias/helper: under the hood it builds `filters_query` per facet (AND/OR) and applies bucket options. If you also pass legacy params, priority is: `filters_query` > `facets` > `filters`.
258
+
259
+
Ideal for React/Vue/Next UIs that need runtime toggles (AND/OR, “show more”, bucket sorting) without recreating the engine.
260
+
233
261
### `itemsjs.aggregation(options)`
234
262
235
263
It returns full list of filters for specific aggregation
0 commit comments