Loading TOC...


   $name as xs.string,
   $index as cts.reference
) as FacetDefinition


Creates a FacetDefinition object to define the value enumeration as part of a facet search.

$name The name of the facet.
$index A cts.jsonPropertyReference, cts.elementReference, cts.fieldReference, or other reference to the range index or other values lexicon with the values for the facet. You can use a string for a JSON property name as a shortcut for a cts.jsonPropertyReference. You can pass multiple references or multiple property-name strings (but not both) for a union of values with the same datatype from multiple range indexes.

Usage Notes

Use facet definitions as input to jsearch.facets. Use the methods of FacetDefinition to refine your facet.

A facet definition can have the following form. Only the facet is required.

facet(facetName, propertyNameOrIndexRef)
  .map(configOrFuncRef) | .reduce(configOrFuncRef)

See Also


// Construct a facet labeled "Author" on the "author" JSON property
jsearch.facet('Author', 'author')


// Construct a facet labeled "Author" on the "author" JSON property, but
// do not include frequency data in the results.
jsearch.facet('Author', 'author').map({frequency: 'none'})


// Construct a facet labeled "Price" on the "price" JSON property.
// Group the facet values in value range buckets of (X < 10),
// (10 <= X < 20), and (x >= 20)
    jsearch.bucketName('under $10'), 10,
    jsearch.bucketName('$10 to $19.99'), 20,
    jsearch.bucketName('over $20'), 1000

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.


The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.