
jsearch.facet( 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.
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)
// 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.facet('Price','price')
.groupInto([
jsearch.bucketName('under $10'), 10,
jsearch.bucketName('$10 to $19.99'), 20,
jsearch.bucketName('over $20'), 1000
])
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.