Loading TOC...

jsearch.facet

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

Summary

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

Parameters
$nameThe 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)
  .othersWhere(queries)
  .thisWhere(queries)
  .groupInto(bucketDefinitions)
  .orderBy(orderingConfig)
  .slice(paginationConfig)
  .map(configOrFuncRef) | .reduce(configOrFuncRef)
  .withOptions(optionsConfig)
    

See Also

Example


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

Example


// 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'})
   

Example


// 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.facet('Price','price')
  .groupInto([
    jsearch.bucketName('under $10'), 10,
    jsearch.bucketName('$10 to $19.99'), 20,
    jsearch.bucketName('over $20'), 1000
  ])
   

Comments

    Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy