Loading TOC...

FacetsSearch functions (FacetsSearch)

Use these functions to generate facets from values in a lexicon or range index. You can generate facets in combination with a document search and from an arbitrary set of documents in the database.

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 chain together the methods of this class matters. You should preserve the ordering 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 calls to facets and result being optional.

jsearch.facets(facetDefinitions, srcDocuments)    // creates a FacetsSearch obj
  .where(queries)
  .withOptions(optionsConfig)
  .result()
    

Use jsearch.facet and the FacetDefinition methods to create the input facet definitions.

For details, see jsearch.facets, FacetsSearch, FacetsDefinition, and Including Facets in Search Results in the Search Developer's Guide.

3 functions
Function name Description
FacetsSearch.result Executes the facets search definition and returns the results.
FacetsSearch.where Specify one or an array of cts.query's used to qualify the facet values and the document result set (if requested).
FacetsSearch.withOptions Configure advanced options for facet generation.