Use these functions to build a facet definition for use with
jsearch.facets
and FacetsSearch
.
To use this module in your Server-Side JavaScript code, include a
require
statement similar to following line in your code:
const jsearch = require("/MarkLogic/jsearch");
The order in which you call the methods of this class is significant. You should preserve the order shown in the template below. For details, see Query Design Pattern in the Search Developer's Guide.
The intended usage is as follows, with everything
except the call to documents
and result
being optional.
jsearch.facet() // creates a FacetDefinition object
.where(queries)
.othersWhere(queries)
.thisWhere(queries)
.groupInto(bucketDefinition)
.orderBy(jsonPropNameOrIndexReference)
.slice(startPos, endPosPlusOne)
.map(configOrFuncRef) | .reduce(configOrFuncRef)
.withOptions(optionsConfig)
The where
, orderBy
, slice
,
map
, reduce
, and withOptions
methods behave as for a values query.
For details, see jsearch.facets, FacetsSearch, and Including Facets in Search Results in the Search Developer's Guide.
Function name | Description |
---|---|
FacetDefinition.groupInto | Groups facet values into buckets between bound values as in a ValuesSearch definition. |
FacetDefinition.map | Specifies a function similar to Array.prototype.map() to apply to each value within the slice or the configuration for the built-in mapper, as in a ValuesSearch definition. |
FacetDefinition.orderBy | Specifies the sort order for facet values, as in a ValuesSearch definition. |
FacetDefinition.othersWhere | Specify a query to apply to facets other than this one. |
FacetDefinition.reduce | Specifies a function similar to Array.prototype.reduce() to apply to each value within the slice or a configuration object for the built-in reducer, as in a ValuesSearch definition. |
FacetDefinition.slice | Specifies a subsequence of values to retrieve as in a ValuesSearch definition. |
FacetDefinition.thisWhere | Specify a query to apply only to this facet. |
FacetDefinition.withOptions | Configure advanced options for facet generation. |