Loading TOC...

FacetsSearch.where

FacetsSearch.where(
   $queries as cts.query
) as FacetsSearch

Summary

Specify one or an array of cts.query's used to qualify the facet values and the document result set (if requested).

Parameters
$queries One or an array of cts.query objects. Some helper functions such as cts.parse() and jsearch.byExample() return a cts.query object.

Usage Notes

If your facet operation also includes a documents query, then the where clause of that query qualify only the documents. By contrast, this where can be used to qualify both the facet values and any returned documents.

See Also

Example


// Generate facets for the author and format JSON properties. Include
// only those values that occur in documents where the price JSON 
// property values is less than 15.
const jsearch = require('/MarkLogic/jsearch.sjs');
jsearch.facets([
    jsearch.facet('Author', 'author'),
    jsearch.facet('MediaFormat', 'format')])
  .where(jsearch.byExample({price: {$lt: 15}}))
  .result()
   

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

Comments

The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.
  • How can I set options for the search using this model? I'd like to use score-simple rather than the default score-tfidf.
    • You include options in the construction of the query you pass to the where clause. For example, in a call to cts.elementRangeQuery. The exact way to specify it will vary depending on how you're constructing your query (cts constructor, jsearch.byExample, cts.parse). See also http://docs.marklogic.com/8.0/guide/search-dev/javascript#id_26946.
      • Kim - the score-simple option is an option to cts.search, not cts.query. I found out in the meantime that we pass this option to jsearch.documents().withOptions() and you can pass jsearch.documents as a parameter to jsearch.facets.