Loading TOC...


   qbe as objectOrNode
) as cts.query


Constructs a cts.query working by example.

qbe A JavaScript object, JSON node, or XML node that expresses query criteria using Query By Example (QBE) syntax.

Usage Notes

Use this method to construct a cts.query using syntax that closely resemble the content you want to match. The syntax is based on Query By Example (QBE), but contains some differences. For details, see Differences Between byExample and QBE in the Search Developer's Guide.

See Also


// Matches documents where the "author" JSON property has the value "Mark Twain"
const jsearch = require('/MarkLogic/jsearch.sjs');
  .where( jsearch.byExample({author: 'Mark Twain'}) )


// Match all the following conditions:
// - The "title" JSON property has the value "adventures of tom sawyer"
// - The "author" JSON property contains the term "mark" within 2 terms of
//   the term "twain"
// - The "format" JSON property within "edition" property has the value 
//   "paperback" or the value "hardback"
// - The "price" JSON property value is less than 10.00 and greater or
//   or equal to 8.00
  "title": {
    "$value": "adventures of tom sawyer",
    "$exact": false
  "$near": [
    { "author": { "$word": "mark" } },
    { "author": { "$word": "twain" } }
  ], "$distance": 2,
  "edition": {
    "$or" : [
      { "format": "paperback" },
      { "format": "hardback" }
  "$and": [
    {"price": { "$lt": 10.00 }},
    {"price": { "$ge": 8.00 }}

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